diff options
author | Oleksandr Koval <oleksandr.koval.dev@gmail.com> | 2020-09-09 12:49:35 (GMT) |
---|---|---|
committer | Oleksandr Koval <oleksandr.koval.dev@gmail.com> | 2020-09-09 12:49:35 (GMT) |
commit | 62d7acc6d4f2e4563b5a71d6e5c90352bf732c79 (patch) | |
tree | 8da5b452aeb392d31f817a4b1655f671d7534d26 /Source/cmCommandArgumentParserHelper.h | |
parent | 9a0a5f84208f652d3ce84e141adf7e9b304574cb (diff) | |
download | CMake-62d7acc6d4f2e4563b5a71d6e5c90352bf732c79.zip CMake-62d7acc6d4f2e4563b5a71d6e5c90352bf732c79.tar.gz CMake-62d7acc6d4f2e4563b5a71d6e5c90352bf732c79.tar.bz2 |
cmCommandArgumentParserHelper: rework input handling
Old implementation uses involved Flex input management technique that
requires usage of obsolete YY_INPUT macro. This causes a lot of useless
allocations and byte-by-byte scanning. New implementation avoids those
hacks, it uses yy_scan_string() API to setup Flex input. Also it fixes
reporting of syntax error position and corresponding tests.
Diffstat (limited to 'Source/cmCommandArgumentParserHelper.h')
-rw-r--r-- | Source/cmCommandArgumentParserHelper.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index 8ff689e..f79ca2c 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -25,7 +25,7 @@ public: cmCommandArgumentParserHelper& operator=( cmCommandArgumentParserHelper const&) = delete; - int ParseString(const char* str, int verb); + int ParseString(std::string const& str, int verb); // For the lexer: void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt, @@ -33,7 +33,6 @@ public: bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt, char symbol); - int LexInput(char* buf, int maxlen); void Error(const char* str); // For yacc @@ -46,6 +45,8 @@ public: void SetMakefile(const cmMakefile* mf); + void UpdateInputPosition(int tokenLength); + std::string& GetResult() { return this->Result; } void SetLineFile(long line, const char* file); @@ -57,8 +58,9 @@ public: const char* GetError() { return this->ErrorString.c_str(); } private: - std::string::size_type InputBufferPos; - std::string InputBuffer; + std::string::size_type InputBufferPos{ 1 }; + std::string::size_type LastTokenLength{}; + std::string::size_type InputSize{}; std::vector<char> OutputBuffer; void Print(const char* place, const char* str); @@ -75,7 +77,6 @@ private: std::string ErrorString; const char* FileName; long FileLine; - int CurrentLine; int Verbose; bool EscapeQuotes; bool NoEscapeMode; |