cmCommandArgumentParserHelper.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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);
  47. void SetResult(const char* value);
  48. void SetMakefile(const cmMakefile* mf);
  49. std::string& GetResult() { return this->Result; }
  50. void SetLineFile(long line, const char* file);
  51. void SetEscapeQuotes(bool b) { this->EscapeQuotes = b; }
  52. void SetNoEscapeMode(bool b) { this->NoEscapeMode = 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. std::vector<char*> Variables;
  73. const cmMakefile* Makefile;
  74. std::string Result;
  75. const char* FileName;
  76. long FileLine;
  77. bool EscapeQuotes;
  78. std::string ErrorString;
  79. bool NoEscapeMode;
  80. };
  81. #endif