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
|
cmFortranParser.y
|
||||||
|
|
||||||
Modify cmFortranParser.cxx:
|
Modify cmFortranParser.cxx:
|
||||||
- remove TABs
|
- "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
|
||||||
- remove use of the 'register' storage class specifier
|
|
||||||
- Remove the yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
@ -44,18 +42,11 @@ Modify cmFortranParser.cxx:
|
||||||
|
|
||||||
#include <cmsys/String.h>
|
#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. */
|
/* Forward declare the lexer entry point. */
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
/* Helper function to forward error callback. */
|
/* Helper function to forward error callback from parser. */
|
||||||
static void cmFortranError(yyscan_t yyscanner, const char* message)
|
static void cmFortran_yyerror(yyscan_t yyscanner, const char* message)
|
||||||
{
|
{
|
||||||
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
||||||
cmFortranParser_Error(parser, message);
|
cmFortranParser_Error(parser, message);
|
||||||
|
@ -79,7 +70,13 @@ static bool cmFortranParserIsKeyword(const char* word,
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Generate a reentrant parser object. */
|
/* 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 {
|
%union {
|
||||||
char* string;
|
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
|
/* 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -30,43 +30,51 @@
|
||||||
This special exception was added by the Free Software Foundation in
|
This special exception was added by the Free Software Foundation in
|
||||||
version 2.2 of Bison. */
|
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
|
#ifndef YYTOKENTYPE
|
||||||
# define YYTOKENTYPE
|
# define YYTOKENTYPE
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
enum yytokentype
|
||||||
know about them. */
|
{
|
||||||
enum yytokentype {
|
EOSTMT = 258,
|
||||||
EOSTMT = 258,
|
ASSIGNMENT_OP = 259,
|
||||||
ASSIGNMENT_OP = 259,
|
GARBAGE = 260,
|
||||||
GARBAGE = 260,
|
CPP_INCLUDE = 261,
|
||||||
CPP_INCLUDE = 261,
|
F90PPR_INCLUDE = 262,
|
||||||
F90PPR_INCLUDE = 262,
|
COCO_INCLUDE = 263,
|
||||||
COCO_INCLUDE = 263,
|
F90PPR_DEFINE = 264,
|
||||||
F90PPR_DEFINE = 264,
|
CPP_DEFINE = 265,
|
||||||
CPP_DEFINE = 265,
|
F90PPR_UNDEF = 266,
|
||||||
F90PPR_UNDEF = 266,
|
CPP_UNDEF = 267,
|
||||||
CPP_UNDEF = 267,
|
CPP_IFDEF = 268,
|
||||||
CPP_IFDEF = 268,
|
CPP_IFNDEF = 269,
|
||||||
CPP_IFNDEF = 269,
|
CPP_IF = 270,
|
||||||
CPP_IF = 270,
|
CPP_ELSE = 271,
|
||||||
CPP_ELSE = 271,
|
CPP_ELIF = 272,
|
||||||
CPP_ELIF = 272,
|
CPP_ENDIF = 273,
|
||||||
CPP_ENDIF = 273,
|
F90PPR_IFDEF = 274,
|
||||||
F90PPR_IFDEF = 274,
|
F90PPR_IFNDEF = 275,
|
||||||
F90PPR_IFNDEF = 275,
|
F90PPR_IF = 276,
|
||||||
F90PPR_IF = 276,
|
F90PPR_ELSE = 277,
|
||||||
F90PPR_ELSE = 277,
|
F90PPR_ELIF = 278,
|
||||||
F90PPR_ELIF = 278,
|
F90PPR_ENDIF = 279,
|
||||||
F90PPR_ENDIF = 279,
|
COMMA = 280,
|
||||||
COMMA = 280,
|
DCOLON = 281,
|
||||||
DCOLON = 281,
|
CPP_TOENDL = 282,
|
||||||
CPP_TOENDL = 282,
|
UNTERMINATED_STRING = 283,
|
||||||
UNTERMINATED_STRING = 283,
|
STRING = 284,
|
||||||
STRING = 284,
|
WORD = 285,
|
||||||
WORD = 285,
|
CPP_INCLUDE_ANGLE = 286
|
||||||
CPP_INCLUDE_ANGLE = 286
|
};
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#define EOSTMT 258
|
#define EOSTMT 258
|
||||||
|
@ -99,24 +107,23 @@
|
||||||
#define WORD 285
|
#define WORD 285
|
||||||
#define CPP_INCLUDE_ANGLE 286
|
#define CPP_INCLUDE_ANGLE 286
|
||||||
|
|
||||||
|
/* Value type. */
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
typedef union YYSTYPE
|
typedef union YYSTYPE YYSTYPE;
|
||||||
|
union YYSTYPE
|
||||||
{
|
{
|
||||||
|
#line 81 "cmFortranParser.y" /* yacc.c:1909 */
|
||||||
/* Line 2068 of yacc.c */
|
|
||||||
#line 89 "cmFortranParser.y"
|
|
||||||
|
|
||||||
char* string;
|
char* string;
|
||||||
|
|
||||||
|
#line 120 "cmFortranParserTokens.h" /* yacc.c:1909 */
|
||||||
|
};
|
||||||
/* Line 2068 of yacc.c */
|
|
||||||
#line 118 "cmFortranParserTokens.h"
|
|
||||||
} YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cmFortran_yyparse (yyscan_t yyscanner);
|
||||||
|
|
||||||
|
#endif /* !YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED */
|
||||||
|
|
Loading…
Reference in New Issue