cmCommandArgumentParserHelper.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmCommandArgumentParserHelper_h
  14. #define cmCommandArgumentParserHelper_h
  15. #include "cmStandardIncludes.h"
  16. #define YYSTYPE cmCommandArgumentParserHelper::ParserType
  17. #define YYSTYPE_IS_DECLARED
  18. #define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
  19. #define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp,\
  20. yyscan_t yyscanner)
  21. /** \class cmCommandArgumentParserHelper
  22. * \brief Helper class for parsing java source files
  23. *
  24. * Finds dependencies for java file and list of outputs
  25. */
  26. class cmMakefile;
  27. class cmCommandArgumentParserHelper
  28. {
  29. public:
  30. typedef struct {
  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, bool doingAt=false);
  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. void SetAtOnly(bool b) { this->AtOnly = b; }
  57. const char* GetError() { return this->ErrorString.c_str(); }
  58. char EmptyVariable[1];
  59. char DCURLYVariable[3];
  60. char RCURLYVariable[3];
  61. char ATVariable[3];
  62. char DOLLARVariable[3];
  63. char LCURLYVariable[3];
  64. char BSLASHVariable[3];
  65. private:
  66. cmStdString::size_type InputBufferPos;
  67. cmStdString InputBuffer;
  68. std::vector<char> OutputBuffer;
  69. int CurrentLine;
  70. int UnionsAvailable;
  71. int Verbose;
  72. void Print(const char* place, const char* str);
  73. void SafePrintMissing(const char* str, int line, int cnt);
  74. char* AddString(const char* str);
  75. void CleanupParser();
  76. std::vector<char*> Variables;
  77. const cmMakefile* Makefile;
  78. std::string Result;
  79. const char* FileName;
  80. long FileLine;
  81. bool EscapeQuotes;
  82. std::string ErrorString;
  83. bool NoEscapeMode;
  84. bool ReplaceAtSyntax;
  85. bool RemoveEmpty;
  86. bool AtOnly;
  87. };
  88. #endif