cmCommandArgumentParserHelper.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmCommandArgumentParserHelper_h
  4. #define cmCommandArgumentParserHelper_h
  5. #include "cmConfigure.h"
  6. #include <string>
  7. #include <vector>
  8. class cmMakefile;
  9. class cmCommandArgumentParserHelper
  10. {
  11. CM_DISABLE_COPY(cmCommandArgumentParserHelper)
  12. public:
  13. struct ParserType
  14. {
  15. char* str;
  16. };
  17. cmCommandArgumentParserHelper();
  18. ~cmCommandArgumentParserHelper();
  19. int ParseString(const char* str, int verb);
  20. // For the lexer:
  21. void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
  22. const char* str, int len = 0);
  23. bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
  24. char symbol);
  25. int LexInput(char* buf, int maxlen);
  26. void Error(const char* str);
  27. // For yacc
  28. char* CombineUnions(char* in1, char* in2);
  29. char* ExpandSpecialVariable(const char* key, const char* var);
  30. char* ExpandVariable(const char* var);
  31. char* ExpandVariableForAt(const char* var);
  32. void SetResult(const char* value);
  33. void SetMakefile(const cmMakefile* mf);
  34. std::string& GetResult() { return this->Result; }
  35. void SetLineFile(long line, const char* file);
  36. void SetEscapeQuotes(bool b) { this->EscapeQuotes = b; }
  37. void SetNoEscapeMode(bool b) { this->NoEscapeMode = b; }
  38. void SetReplaceAtSyntax(bool b) { this->ReplaceAtSyntax = b; }
  39. void SetRemoveEmpty(bool b) { this->RemoveEmpty = b; }
  40. const char* GetError() { return this->ErrorString.c_str(); }
  41. char EmptyVariable[1];
  42. char DCURLYVariable[3];
  43. char RCURLYVariable[3];
  44. char ATVariable[3];
  45. char DOLLARVariable[3];
  46. char LCURLYVariable[3];
  47. char BSLASHVariable[3];
  48. private:
  49. std::string::size_type InputBufferPos;
  50. std::string InputBuffer;
  51. std::vector<char> OutputBuffer;
  52. void Print(const char* place, const char* str);
  53. void SafePrintMissing(const char* str, int line, int cnt);
  54. char* AddString(const std::string& str);
  55. void CleanupParser();
  56. void SetError(std::string const& msg);
  57. std::vector<char*> Variables;
  58. const cmMakefile* Makefile;
  59. std::string Result;
  60. std::string ErrorString;
  61. const char* FileName;
  62. long FileLine;
  63. int CurrentLine;
  64. int Verbose;
  65. bool WarnUninitialized;
  66. bool CheckSystemVars;
  67. bool EscapeQuotes;
  68. bool NoEscapeMode;
  69. bool ReplaceAtSyntax;
  70. bool RemoveEmpty;
  71. };
  72. #define YYSTYPE cmCommandArgumentParserHelper::ParserType
  73. #define YYSTYPE_IS_DECLARED
  74. #define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
  75. #define YY_DECL \
  76. int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
  77. #endif