cmCommandArgumentParserHelper.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 <cmConfigure.h> // IWYU pragma: keep
  13. #include <string>
  14. #include <vector>
  15. #define YYSTYPE cmCommandArgumentParserHelper::ParserType
  16. #define YYSTYPE_IS_DECLARED
  17. #define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
  18. #define YY_DECL \
  19. int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
  20. /** \class cmCommandArgumentParserHelper
  21. * \brief Helper class for parsing java source files
  22. *
  23. * Finds dependencies for java file and list of outputs
  24. */
  25. class cmMakefile;
  26. class cmCommandArgumentParserHelper
  27. {
  28. public:
  29. typedef struct
  30. {
  31. char* str;
  32. } ParserType;
  33. cmCommandArgumentParserHelper();
  34. ~cmCommandArgumentParserHelper();
  35. int ParseString(const char* str, int verb);
  36. // For the lexer:
  37. void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
  38. const char* str, int len = 0);
  39. bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
  40. char symbol);
  41. int LexInput(char* buf, int maxlen);
  42. void Error(const char* str);
  43. // For yacc
  44. char* CombineUnions(char* in1, char* in2);
  45. char* ExpandSpecialVariable(const char* key, const char* var);
  46. char* ExpandVariable(const char* var);
  47. char* ExpandVariableForAt(const char* var);
  48. void SetResult(const char* value);
  49. void SetMakefile(const cmMakefile* mf);
  50. std::string& GetResult() { return this->Result; }
  51. void SetLineFile(long line, const char* file);
  52. void SetEscapeQuotes(bool b) { this->EscapeQuotes = b; }
  53. void SetNoEscapeMode(bool b) { this->NoEscapeMode = b; }
  54. void SetReplaceAtSyntax(bool b) { this->ReplaceAtSyntax = b; }
  55. void SetRemoveEmpty(bool b) { this->RemoveEmpty = b; }
  56. const char* GetError() { return this->ErrorString.c_str(); }
  57. char EmptyVariable[1];
  58. char DCURLYVariable[3];
  59. char RCURLYVariable[3];
  60. char ATVariable[3];
  61. char DOLLARVariable[3];
  62. char LCURLYVariable[3];
  63. char BSLASHVariable[3];
  64. private:
  65. std::string::size_type InputBufferPos;
  66. std::string InputBuffer;
  67. std::vector<char> OutputBuffer;
  68. void Print(const char* place, const char* str);
  69. void SafePrintMissing(const char* str, int line, int cnt);
  70. char* AddString(const std::string& 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. std::string ErrorString;
  77. const char* FileName;
  78. long FileLine;
  79. int CurrentLine;
  80. int Verbose;
  81. bool WarnUninitialized;
  82. bool CheckSystemVars;
  83. bool EscapeQuotes;
  84. bool NoEscapeMode;
  85. bool ReplaceAtSyntax;
  86. bool RemoveEmpty;
  87. };
  88. #endif