cmCommandArgumentParserHelper.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. // For the lexer:
  36. void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
  37. const char* str, int len = 0);
  38. int LexInput(char* buf, int maxlen);
  39. void Error(const char* str);
  40. // For yacc
  41. char* CombineUnions(char* in1, char* in2);
  42. char* ExpandSpecialVariable(const char* key, const char* var);
  43. char* ExpandVariable(const char* var);
  44. void SetResult(const char* value);
  45. void SetMakefile(const cmMakefile* mf);
  46. std::string& GetResult() { return m_Result; }
  47. void SetLineFile(long line, const char* file);
  48. void SetEscapeQuotes(bool b) { m_EscapeQuotes = b; }
  49. const char* GetError() { return m_Error.c_str(); }
  50. char m_EmptyVariable[1];
  51. char m_DCURLYVariable[3];
  52. char m_RCURLYVariable[3];
  53. char m_ATVariable[3];
  54. char m_DOLLARVariable[3];
  55. char m_LCURLYVariable[3];
  56. char m_BSLASHVariable[3];
  57. private:
  58. cmStdString::size_type InputBufferPos;
  59. cmStdString InputBuffer;
  60. std::vector<char> OutputBuffer;
  61. int CurrentLine;
  62. int UnionsAvailable;
  63. int Verbose;
  64. void Print(const char* place, const char* str);
  65. void SafePrintMissing(const char* str, int line, int cnt);
  66. char* AddString(const char* str);
  67. void CleanupParser();
  68. std::vector<char*> m_Variables;
  69. const cmMakefile* m_Makefile;
  70. std::string m_Result;
  71. const char* m_FileName;
  72. long m_FileLine;
  73. bool m_EscapeQuotes;
  74. std::string m_Error;
  75. };
  76. #endif