cmFortranParser: 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:
parent
eebe732bb6
commit
ecca8fd908
File diff suppressed because it is too large
Load Diff
|
@ -32,9 +32,7 @@ Run bison like this:
|
|||
cmFortranParser.y
|
||||
|
||||
Modify cmFortranParser.cxx:
|
||||
- remove TABs
|
||||
- remove use of the 'register' storage class specifier
|
||||
- Remove the yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
|
||||
- "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
@ -44,18 +42,11 @@ Modify cmFortranParser.cxx:
|
|||
|
||||
#include <cmsys/String.h>
|
||||
|
||||
/* Configure the parser to use a lexer object. */
|
||||
#define YYPARSE_PARAM yyscanner
|
||||
#define YYLEX_PARAM yyscanner
|
||||
#define YYERROR_VERBOSE 1
|
||||
#define cmFortran_yyerror(x) \
|
||||
cmFortranError(yyscanner, x)
|
||||
|
||||
/* Forward declare the lexer entry point. */
|
||||
YY_DECL;
|
||||
|
||||
/* Helper function to forward error callback. */
|
||||
static void cmFortranError(yyscan_t yyscanner, const char* message)
|
||||
/* Helper function to forward error callback from parser. */
|
||||
static void cmFortran_yyerror(yyscan_t yyscanner, const char* message)
|
||||
{
|
||||
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
||||
cmFortranParser_Error(parser, message);
|
||||
|
@ -79,7 +70,13 @@ static bool cmFortranParserIsKeyword(const char* word,
|
|||
%}
|
||||
|
||||
/* 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 {
|
||||
char* string;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* A Bison parser, made by GNU Bison 2.5. */
|
||||
/* A Bison parser, made by GNU Bison 3.0.2. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -30,13 +30,21 @@
|
|||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
|
||||
# define YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int cmFortran_yydebug;
|
||||
#endif
|
||||
|
||||
/* Tokens. */
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
enum yytokentype
|
||||
{
|
||||
EOSTMT = 258,
|
||||
ASSIGNMENT_OP = 259,
|
||||
GARBAGE = 260,
|
||||
|
@ -99,24 +107,23 @@
|
|||
#define WORD 285
|
||||
#define CPP_INCLUDE_ANGLE 286
|
||||
|
||||
|
||||
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 89 "cmFortranParser.y"
|
||||
#line 81 "cmFortranParser.y" /* yacc.c:1909 */
|
||||
|
||||
char* string;
|
||||
|
||||
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 118 "cmFortranParserTokens.h"
|
||||
} YYSTYPE;
|
||||
#line 120 "cmFortranParserTokens.h" /* yacc.c:1909 */
|
||||
};
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int cmFortran_yyparse (yyscan_t yyscanner);
|
||||
|
||||
#endif /* !YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED */
|
||||
|
|
Loading…
Reference in New Issue