mirror of
https://github.com/reactos/CMake.git
synced 2025-01-19 01:42:18 +00:00
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.
This commit is contained in:
parent
c508fd8481
commit
fe75e140d6
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 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
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -18,9 +15,7 @@
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
@ -35,25 +30,34 @@
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED
|
||||
# define YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int cmCommandArgument_yydebug;
|
||||
#endif
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
cal_ENVCURLY = 258,
|
||||
cal_NCURLY = 259,
|
||||
cal_DCURLY = 260,
|
||||
cal_DOLLAR = 261,
|
||||
cal_LCURLY = 262,
|
||||
cal_RCURLY = 263,
|
||||
cal_NAME = 264,
|
||||
cal_BSLASH = 265,
|
||||
cal_SYMBOL = 266,
|
||||
cal_AT = 267,
|
||||
cal_ERROR = 268,
|
||||
cal_ATNAME = 269
|
||||
};
|
||||
enum yytokentype
|
||||
{
|
||||
cal_ENVCURLY = 258,
|
||||
cal_NCURLY = 259,
|
||||
cal_DCURLY = 260,
|
||||
cal_DOLLAR = 261,
|
||||
cal_LCURLY = 262,
|
||||
cal_RCURLY = 263,
|
||||
cal_NAME = 264,
|
||||
cal_BSLASH = 265,
|
||||
cal_SYMBOL = 266,
|
||||
cal_AT = 267,
|
||||
cal_ERROR = 268,
|
||||
cal_ATNAME = 269
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define cal_ENVCURLY 258
|
||||
@ -69,15 +73,10 @@
|
||||
#define cal_ERROR 268
|
||||
#define cal_ATNAME 269
|
||||
|
||||
/* Value type. */
|
||||
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef int YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
int cmCommandArgument_yyparse (yyscan_t yyscanner);
|
||||
|
||||
#endif /* !YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED */
|
||||
|
Loading…
x
Reference in New Issue
Block a user