Commit 9519d79b authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'math-EXPR-unary'

2810e561 math(EXPR): Add support for unary `+` and `-` expressions
834f52a6 cmExprParser: Revise indentation style to match rest of CMake
7aaed265 cmExprParser: Port to bison 3
parents 086f356f 2810e561
math-EXPR-unary
---------------
* The :command:`math(EXPR)` command gained support for unary
``+`` and ``-`` expressions.
/* A Bison parser, made by GNU Bison 1.875d. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984,
1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
/* Bison implementation for Yacc-like parsers in C
This program is free software; you can redistribute it and/or modify
Copyright (C) 1984, 1989-1990, 2000-2015 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
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
......@@ -14,17 +15,23 @@
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, 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
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Written by Richard Stallman by simplifying the original so called
``semantic'' parser. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
......@@ -33,76 +40,35 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* turn off some warning as this is generated code */
#if defined(_MSC_VER)
# pragma warning ( disable : 4702 ) /* unreachable code */
#endif
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.0.4"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 1
/* Using locations. */
#define YYLSP_NEEDED 0
/* If NAME_PREFIX is specified substitute the variables and functions
names. */
#define yyparse cmExpr_yyparse
#define yylex cmExpr_yylex
#define yyerror cmExpr_yyerror
#define yylval cmExpr_yylval
#define yychar cmExpr_yychar
#define yydebug cmExpr_yydebug
#define yynerrs cmExpr_yynerrs
/* Push parsers. */
#define YYPUSH 0
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
exp_PLUS = 258,
exp_MINUS = 259,
exp_TIMES = 260,
exp_DIVIDE = 261,
exp_MOD = 262,
exp_SHIFTLEFT = 263,
exp_SHIFTRIGHT = 264,
exp_OPENPARENT = 265,
exp_CLOSEPARENT = 266,
exp_OR = 267,
exp_AND = 268,
exp_XOR = 269,
exp_NOT = 270,
exp_NUMBER = 271
};
#endif
#define exp_PLUS 258
#define exp_MINUS 259
#define exp_TIMES 260
#define exp_DIVIDE 261
#define exp_MOD 262
#define exp_SHIFTLEFT 263
#define exp_SHIFTRIGHT 264
#define exp_OPENPARENT 265
#define exp_CLOSEPARENT 266
#define exp_OR 267
#define exp_AND 268
#define exp_XOR 269
#define exp_NOT 270
#define exp_NUMBER 271
/* Pull parsers. */
#define YYPULL 1
/* Substitute the variable and function names. */
#define yyparse cmExpr_yyparse
#define yylex cmExpr_yylex
#define yyerror cmExpr_yyerror
#define yydebug cmExpr_yydebug
#define yynerrs cmExpr_yynerrs
/* Copy the first part of user declarations. */
#line 1 "cmExprParser.y" /* yacc.c:339 */
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
......@@ -112,24 +78,15 @@ This file must be translated to C and modified to build everywhere.
Run bison like this:
bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h
-ocmExprParser.cxx cmExprParser.y
bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y
Modify cmExprParser.cxx:
- remove TABs
- 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 cmExpr_yyerror(x) \
cmExprError(yyscanner, x)
#define yyGetParser (cmExpr_yyget_extra(yyscanner))
/*-------------------------------------------------------------------------*/
#define YYDEBUG 1
#include "cmExprParserHelper.h" /* Interface to parser object. */
#include "cmExprLexer.h" /* Interface to lexer object. */
#include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */
......@@ -139,99 +96,281 @@ Modify cmExprParser.cxx:
/* Forward declare the lexer entry point. */
YY_DECL;
/* Internal utility functions. */
static void cmExprError(yyscan_t yyscanner, const char* message);
#define YYDEBUG 1
//#define YYMAXDEPTH 100000
//#define YYINITDEPTH 10000
/* Helper function to forward error callback from parser. */
static void cmExpr_yyerror(yyscan_t yyscanner, const char* message);
/* Disable some warnings in the generated code. */
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but
no case. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
#endif
#line 109 "cmExprParser.cxx" /* yacc.c:339 */
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
# define YYERROR_VERBOSE 1
#endif
#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
/* In a future release of Bison, this section will be replaced
by #include "cmExprParserTokens.h". */
#ifndef YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
# define YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int cmExpr_yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
exp_PLUS = 258,
exp_MINUS = 259,
exp_TIMES = 260,
exp_DIVIDE = 261,
exp_MOD = 262,
exp_SHIFTLEFT = 263,
exp_SHIFTRIGHT = 264,
exp_OPENPARENT = 265,
exp_CLOSEPARENT = 266,
exp_OR = 267,
exp_AND = 268,
exp_XOR = 269,
exp_NOT = 270,
exp_NUMBER = 271
};
#endif
/* Tokens. */
#define exp_PLUS 258
#define exp_MINUS 259
#define exp_TIMES 260
#define exp_DIVIDE 261
#define exp_MOD 262
#define exp_SHIFTLEFT 263
#define exp_SHIFTRIGHT 264
#define exp_OPENPARENT 265
#define exp_CLOSEPARENT 266
#define exp_OR 267
#define exp_AND 268
#define exp_XOR 269
#define exp_NOT 270
#define exp_NUMBER 271
/* Value type. */
int cmExpr_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED */
/* Copy the second part of user declarations. */
#line 186 "cmExprParser.cxx" /* yacc.c:358 */
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
/* Line 214 of yacc.c. */
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#else
typedef signed char yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#if ! defined (yyoverflow) || YYERROR_VERBOSE
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
# ifndef YYFREE
# define YYFREE free
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(Msgid) Msgid
# endif
#endif
#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
# define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# define YYSTACK_ALLOC alloca
# endif
# else
# if defined (alloca) || defined (_ALLOCA_H)
# define YYSTACK_ALLOC alloca
# else
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
/* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined (yyoverflow) \
&& (! defined (__cplusplus) \
|| (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
short int yyss;
YYSTYPE yyvs;
};
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
......@@ -239,74 +378,74 @@ union yyalloc
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined (__GNUC__) && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (0)
# endif
# endif
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#endif
#if defined (__STDC__) || defined (__cplusplus)
typedef signed char yysigned_char;
#else
typedef short int yysigned_char;
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 12
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 17
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 25
#define YYLAST 30
/* YYNTOKENS -- Number of terminals. */
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 17
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 9
/* YYNRULES -- Number of rules. */
#define YYNRULES 20
/* YYNRULES -- Number of states. */
#define YYNSTATES 34
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 10
/* YYNRULES -- Number of rules. */
#define YYNRULES 23
/* YYNSTATES -- Number of states. */
#define YYNSTATES 39
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 271
#define YYTRANSLATE(YYX) \
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
static const unsigned char yytranslate[] =
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
......@@ -339,210 +478,161 @@ static const unsigned char yytranslate[] =
};
#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
static const unsigned char yyprhs[] =
{
0, 0, 3, 5, 7, 11, 13, 17, 19, 23,
25, 29, 33, 35, 39, 43, 45, 49, 53, 57,
59
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yysigned_char yyrhs[] =
{
18, 0, -1, 19, -1, 20, -1, 19, 12, 20,
-1, 21, -1, 20, 14, 21, -1, 22, -1, 21,
13, 22, -1, 23, -1, 22, 8, 23, -1, 22,
9, 23, -1, 24, -1, 23, 3, 24, -1, 23,
4, 24, -1, 25, -1, 24, 5, 25, -1, 24,
6, 25, -1, 24, 7, 25, -1, 16,