cmCommandArgumentParserHelper.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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, 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. char* str;
  31. } ParserType;
  32. cmCommandArgumentParserHelper();
  33. ~cmCommandArgumentParserHelper();
  34. int ParseString(const char* str, int verb);
  35. int ParseFile(const char* file);
  36. // For the lexer:
  37. void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
  38. const char* str, int len = 0);
  39. int LexInput(char* buf, int maxlen);
  40. void Error(const char* str);
  41. // For yacc
  42. void AddClassFound(const char* sclass);
  43. void PrepareElement(ParserType* opt);
  44. void DeallocateParserType(char** pt);
  45. void CheckEmpty(int line, int cnt, ParserType* pt);
  46. void StartClass(const char* cls);
  47. void EndClass();
  48. void AddPackagesImport(const char* sclass);
  49. void SetCurrentCombine(const char* cmb) { this->CurrentCombine = cmb; }
  50. const char* GetCurrentCombine() { return this->CurrentCombine.c_str(); }
  51. void UpdateCombine(const char* str1, const char* str2);
  52. void Append(const char* str);
  53. char* CombineUnions(char* in1, char* in2);
  54. char* ExpandSpecialVariable(const char* key, const char* var);
  55. char* ExpandVariable(const char* var);
  56. void SetResult(const char* value);
  57. void SetMakefile(const cmMakefile* mf);
  58. std::string& GetResult() { return m_Result; }
  59. void SetLineFile(long line, const char* file);
  60. void SetEscapeQuotes(bool b) { m_EscapeQuotes = b; }
  61. const char* GetError() { return m_Error.c_str(); }
  62. char m_EmptyVariable[1];
  63. char m_DCURLYVariable[3];
  64. char m_RCURLYVariable[3];
  65. char m_ATVariable[3];
  66. char m_DOLLARVariable[3];
  67. char m_LCURLYVariable[3];
  68. char m_BSLASHVariable[3];
  69. private:
  70. cmStdString::size_type InputBufferPos;
  71. cmStdString InputBuffer;
  72. std::vector<char> OutputBuffer;
  73. int CurrentLine;
  74. int UnionsAvailable;
  75. int Verbose;
  76. std::vector<char*> Allocates;
  77. std::string CurrentCombine;
  78. void PrintClasses();
  79. void Print(const char* place, const char* str);
  80. void SafePrintMissing(const char* str, int line, int cnt);
  81. char* AddString(const char* str);
  82. void CleanupParser();
  83. std::set<char*> m_Variables;
  84. const cmMakefile* m_Makefile;
  85. std::string m_Result;
  86. const char* m_FileName;
  87. long m_FileLine;
  88. bool m_EscapeQuotes;
  89. std::string m_Error;
  90. };
  91. #endif