diff options
author | Brad King <brad.king@kitware.com> | 2016-10-14 19:08:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-10-14 19:30:49 (GMT) |
commit | 7aaed265ade4c3b38967e83095497280a7a55153 (patch) | |
tree | 74dd6f8bb1368ba8783ed034c113a70ef5e594cf /Source/cmExprParser.y | |
parent | 0d818632978a450f1afaf687c867e62e885457f7 (diff) | |
download | CMake-7aaed265ade4c3b38967e83095497280a7a55153.zip CMake-7aaed265ade4c3b38967e83095497280a7a55153.tar.gz CMake-7aaed265ade4c3b38967e83095497280a7a55153.tar.bz2 |
cmExprParser: 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/cmExprParser.y')
-rw-r--r-- | Source/cmExprParser.y | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/Source/cmExprParser.y b/Source/cmExprParser.y index a265c20..b511fa7 100644 --- a/Source/cmExprParser.y +++ b/Source/cmExprParser.y @@ -10,21 +10,12 @@ Run bison like this: bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y Modify cmExprParser.cxx: - - remove TABs - - remove use of the 'register' storage class specifier - - add __HP_aCC to the #if test for yyerrorlab warning suppression + - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] */ -/* Configure the parser to use a lexer object. */ -#define YYPARSE_PARAM yyscanner -#define YYLEX_PARAM yyscanner -#define YYERROR_VERBOSE 1 -#define cmExpr_yyerror(x) \ - cmExprError(yyscanner, x) -#define yyGetParser (cmExpr_yyget_extra(yyscanner)) - /*-------------------------------------------------------------------------*/ +#define YYDEBUG 1 #include "cmExprParserHelper.h" /* Interface to parser object. */ #include "cmExprLexer.h" /* Interface to lexer object. */ #include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */ @@ -34,13 +25,8 @@ Modify cmExprParser.cxx: /* Forward declare the lexer entry point. */ YY_DECL; -/* Internal utility functions. */ -static void cmExprError(yyscan_t yyscanner, const char* message); - -#define YYDEBUG 1 -//#define YYMAXDEPTH 100000 -//#define YYINITDEPTH 10000 - +/* Helper function to forward error callback from parser. */ +static void cmExpr_yyerror(yyscan_t yyscanner, const char* message); /* Disable some warnings in the generated code. */ #ifdef _MSC_VER @@ -50,7 +36,13 @@ static void cmExprError(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 /*-------------------------------------------------------------------------*/ /* Tokens */ @@ -77,7 +69,7 @@ static void cmExprError(yyscan_t yyscanner, const char* message); Start: exp { - yyGetParser->SetResult($<Number>1); + cmExpr_yyget_extra(yyscanner)->SetResult($<Number>1); } exp: @@ -148,8 +140,8 @@ exp_OPENPARENT exp exp_CLOSEPARENT /* End of grammar */ /*--------------------------------------------------------------------------*/ -void cmExprError(yyscan_t yyscanner, const char* message) +void cmExpr_yyerror(yyscan_t yyscanner, const char* message) { - yyGetParser->Error(message); + cmExpr_yyget_extra(yyscanner)->Error(message); } |