mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 04:40:18 -05:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user