mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-25 15:49:08 -05: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:
+599
-686
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
|
bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y
|
||||||
|
|
||||||
Modify cmCommandArgumentParser.cxx:
|
Modify cmCommandArgumentParser.cxx:
|
||||||
- remove TABs
|
- "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
|
||||||
- remove use of the 'register' storage class specifier
|
|
||||||
- put header block at top of file
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#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))
|
#define yyGetParser (cmCommandArgument_yyget_extra(yyscanner))
|
||||||
|
|
||||||
/* Make sure malloc and free are available on QNX. */
|
/* Make sure malloc and free are available on QNX. */
|
||||||
@@ -46,10 +38,9 @@ Modify cmCommandArgumentParser.cxx:
|
|||||||
/* Forward declare the lexer entry point. */
|
/* Forward declare the lexer entry point. */
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
/* Internal utility functions. */
|
/* Helper function to forward error callback from parser. */
|
||||||
static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
|
static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message);
|
||||||
|
|
||||||
#define YYDEBUG 1
|
|
||||||
/* Configure the parser to support large input. */
|
/* Configure the parser to support large input. */
|
||||||
#define YYMAXDEPTH 100000
|
#define YYMAXDEPTH 100000
|
||||||
#define YYINITDEPTH 10000
|
#define YYINITDEPTH 10000
|
||||||
@@ -65,7 +56,13 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
/* 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 {
|
||||||
@@ -224,7 +221,7 @@ Variable
|
|||||||
/* End of grammar */
|
/* End of grammar */
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
void cmCommandArgumentError(yyscan_t yyscanner, const char* message)
|
void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message)
|
||||||
{
|
{
|
||||||
yyGetParser->Error(message);
|
yyGetParser->Error(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* 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
|
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||||
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
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
@@ -18,9 +15,7 @@
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
/* As a special exception, you may create a larger work that contains
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
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
|
This special exception was added by the Free Software Foundation in
|
||||||
version 2.2 of Bison. */
|
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
|
#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 {
|
cal_ENVCURLY = 258,
|
||||||
cal_ENVCURLY = 258,
|
cal_NCURLY = 259,
|
||||||
cal_NCURLY = 259,
|
cal_DCURLY = 260,
|
||||||
cal_DCURLY = 260,
|
cal_DOLLAR = 261,
|
||||||
cal_DOLLAR = 261,
|
cal_LCURLY = 262,
|
||||||
cal_LCURLY = 262,
|
cal_RCURLY = 263,
|
||||||
cal_RCURLY = 263,
|
cal_NAME = 264,
|
||||||
cal_NAME = 264,
|
cal_BSLASH = 265,
|
||||||
cal_BSLASH = 265,
|
cal_SYMBOL = 266,
|
||||||
cal_SYMBOL = 266,
|
cal_AT = 267,
|
||||||
cal_AT = 267,
|
cal_ERROR = 268,
|
||||||
cal_ERROR = 268,
|
cal_ATNAME = 269
|
||||||
cal_ATNAME = 269
|
};
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#define cal_ENVCURLY 258
|
#define cal_ENVCURLY 258
|
||||||
@@ -69,15 +73,10 @@
|
|||||||
#define cal_ERROR 268
|
#define cal_ERROR 268
|
||||||
#define cal_ATNAME 269
|
#define cal_ATNAME 269
|
||||||
|
|
||||||
|
/* Value type. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
int cmCommandArgument_yyparse (yyscan_t yyscanner);
|
||||||
typedef int YYSTYPE;
|
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED */
|
||||||
|
|||||||
Reference in New Issue
Block a user