cmCommandArgumentParserHelper.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCommandArgumentParserHelper_h
  11. #define cmCommandArgumentParserHelper_h
  12. #include "cmStandardIncludes.h"
  13. #define YYSTYPE cmCommandArgumentParserHelper::ParserType
  14. #define YYSTYPE_IS_DECLARED
  15. #define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
  16. #define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp,\
  17. yyscan_t yyscanner)
  18. /** \class cmCommandArgumentParserHelper
  19. * \brief Helper class for parsing java source files
  20. *
  21. * Finds dependencies for java file and list of outputs
  22. */
  23. class cmMakefile;
  24. class cmCommandArgumentParserHelper
  25. {
  26. public:
  27. typedef struct {
  28. char* str;
  29. } ParserType;
  30. cmCommandArgumentParserHelper();
  31. ~cmCommandArgumentParserHelper();
  32. int ParseString(const char* str, int verb);
  33. // For the lexer:
  34. void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
  35. const char* str, int len = 0);
  36. bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
  37. char symbol);
  38. int LexInput(char* buf, int maxlen);
  39. void Error(const char* str);
  40. // For yacc
  41. char* CombineUnions(char* in1, char* in2);
  42. char* ExpandSpecialVariable(const char* key, const char* var);
  43. char* ExpandVariable(const char* var);
  44. char* ExpandVariableForAt(const char* var);
  45. void SetResult(const char* value);
  46. void SetMakefile(const cmMakefile* mf);
  47. std::string& GetResult() { return this->Result; }
  48. void SetLineFile(long line, const char* file);
  49. void SetEscapeQuotes(bool b) { this->EscapeQuotes = b; }
  50. void SetNoEscapeMode(bool b) { this->NoEscapeMode = b; }
  51. void SetReplaceAtSyntax(bool b) { this->ReplaceAtSyntax = b; }
  52. void SetRemoveEmpty(bool b) { this->RemoveEmpty = b; }
  53. const char* GetError() { return this->ErrorString.c_str(); }
  54. char EmptyVariable[1];
  55. char DCURLYVariable[3];
  56. char RCURLYVariable[3];
  57. char ATVariable[3];
  58. char DOLLARVariable[3];
  59. char LCURLYVariable[3];
  60. char BSLASHVariable[3];
  61. private:
  62. cmStdString::size_type InputBufferPos;
  63. cmStdString InputBuffer;
  64. std::vector<char> OutputBuffer;
  65. int CurrentLine;
  66. int UnionsAvailable;
  67. int Verbose;
  68. void Print(const char* place, const char* str);
  69. void SafePrintMissing(const char* str, int line, int cnt);
  70. char* AddString(const char* str);
  71. void CleanupParser();
  72. void SetError(std::string const& msg);
  73. std::vector<char*> Variables;
  74. const cmMakefile* Makefile;
  75. std::string Result;
  76. const char* FileName;
  77. bool WarnUninitialized;
  78. bool CheckSystemVars;
  79. long FileLine;
  80. bool EscapeQuotes;
  81. std::string ErrorString;
  82. bool NoEscapeMode;
  83. bool ReplaceAtSyntax;
  84. bool RemoveEmpty;
  85. };
  86. #endif