cmDependsJavaParser: 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.
This commit is contained in:
Daniel Pfeifer
2017-02-16 21:26:36 +01:00
parent fe75e140d6
commit 1728b9c076
3 changed files with 2358 additions and 1942 deletions

View File

@@ -10,18 +10,10 @@ Run bison like this:
bison --yacc --name-prefix=cmDependsJava_yy --defines=cmDependsJavaParserTokens.h -ocmDependsJavaParser.cxx cmDependsJavaParser.y
Modify cmDependsJavaParser.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 cmDependsJava_yyerror(x) \
cmDependsJavaError(yyscanner, x)
#define yyGetParser (cmDependsJava_yyget_extra(yyscanner))
/*-------------------------------------------------------------------------*/
@@ -32,10 +24,9 @@ Modify cmDependsJavaParser.cxx:
/* Forward declare the lexer entry point. */
YY_DECL;
/* Internal utility functions. */
static void cmDependsJavaError(yyscan_t yyscanner, const char* message);
/* Helper function to forward error callback from parser. */
static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message);
#define YYDEBUG 1
#define YYMAXDEPTH 1000000
@@ -50,7 +41,13 @@ static void cmDependsJavaError(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 {
@@ -3205,7 +3202,7 @@ Name jp_DOT jp_NEW
/* End of grammar */
/*--------------------------------------------------------------------------*/
void cmDependsJavaError(yyscan_t yyscanner, const char* message)
void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message)
{
yyGetParser->Error(message);
}