diff options
author | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-02-16 20:18:15 (GMT) |
---|---|---|
committer | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-02-16 20:18:15 (GMT) |
commit | fe75e140d617dd2d8401a85c718d03a6466a8bd9 (patch) | |
tree | 19b3f82319d5ffcba93c62fdc2bcab10722bbb5b /Source/cmCommandArgumentParser.y | |
parent | c508fd8481d87aef7843942ba186d3dea4246c7f (diff) | |
download | CMake-fe75e140d617dd2d8401a85c718d03a6466a8bd9.zip CMake-fe75e140d617dd2d8401a85c718d03a6466a8bd9.tar.gz CMake-fe75e140d617dd2d8401a85c718d03a6466a8bd9.tar.bz2 |
cmCommandArgumentParser: Port to bison 3
Use %-directives to specify the scanner/lexer arguments and update the
yyerror signature. Reduce the list of post-bison modifications needed.
Diffstat (limited to 'Source/cmCommandArgumentParser.y')
-rw-r--r-- | Source/cmCommandArgumentParser.y | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/Source/cmCommandArgumentParser.y b/Source/cmCommandArgumentParser.y index b2f4b1b..9a9ba10 100644 --- a/Source/cmCommandArgumentParser.y +++ b/Source/cmCommandArgumentParser.y @@ -10,20 +10,12 @@ Run bison like this: bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y Modify cmCommandArgumentParser.cxx: - - remove TABs - - remove use of the 'register' storage class specifier - - put header block at top of file + - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] */ #include "cmStandardIncludes.h" -/* Configure the parser to use a lexer object. */ -#define YYPARSE_PARAM yyscanner -#define YYLEX_PARAM yyscanner -#define YYERROR_VERBOSE 1 -#define cmCommandArgument_yyerror(x) \ - cmCommandArgumentError(yyscanner, x) #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner)) /* Make sure malloc and free are available on QNX. */ @@ -46,10 +38,9 @@ Modify cmCommandArgumentParser.cxx: /* Forward declare the lexer entry point. */ YY_DECL; -/* Internal utility functions. */ -static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); +/* Helper function to forward error callback from parser. */ +static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message); -#define YYDEBUG 1 /* Configure the parser to support large input. */ #define YYMAXDEPTH 100000 #define YYINITDEPTH 10000 @@ -65,7 +56,13 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); %} /* Generate a reentrant parser object. */ -%pure_parser +%define api.pure + +/* Configure the parser to use a lexer object. */ +%lex-param {yyscan_t yyscanner} +%parse-param {yyscan_t yyscanner} + +%define parse.error verbose /* %union { @@ -224,7 +221,7 @@ Variable /* End of grammar */ /*--------------------------------------------------------------------------*/ -void cmCommandArgumentError(yyscan_t yyscanner, const char* message) +void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message) { yyGetParser->Error(message); } |