зеркало из https://github.com/AvaloniaUI/angle.git
Update flex/bison binaries.
These binaries were updated using update_flex_bison_binaries.py. Please see instructions in tools/flex-bison/README.md. flex is at version 2.6.4. bison is at version 3.8.2. Bug: None Change-Id: Ia3189b678fc8ddacdf14bbfd3f4750f938d32ac3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3886807 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Родитель
46af4c33ef
Коммит
f39a9659c9
|
@ -6,25 +6,25 @@
|
|||
"src/compiler/preprocessor/preprocessor.l":
|
||||
"31b4f8bc0bb8f713f5e4db8ae04925e2",
|
||||
"src/compiler/preprocessor/preprocessor.y":
|
||||
"df988b6fbdf552ce94bed587679ca574",
|
||||
"770be78579281bd332f2277dcd3be7d3",
|
||||
"src/compiler/preprocessor/preprocessor_lex_autogen.cpp":
|
||||
"77b814881471bcb8c2720a3bc87110de",
|
||||
"85aaf946bef9254abba2ca200a7a4006",
|
||||
"src/compiler/preprocessor/preprocessor_tab_autogen.cpp":
|
||||
"efb77883a5683a8ecf23a7f3aac699c1",
|
||||
"3f15f3cc604a1ac5668711728ddd8430",
|
||||
"tools/flex-bison/linux/bison.sha1":
|
||||
"efa86001f00e7bcfdbe899dd15fc88e0",
|
||||
"6eba651f1769883db395dd4e485ba838",
|
||||
"tools/flex-bison/linux/flex.sha1":
|
||||
"3e73ddbd801cf3e8ed759c49572c8bf2",
|
||||
"tools/flex-bison/windows/bison.exe.sha1":
|
||||
"ad6345f2fbf1112bae67f0d54a92e574",
|
||||
"fd6d2461a2c256179faca7f5f142e689",
|
||||
"tools/flex-bison/windows/flex.exe.sha1":
|
||||
"45668fa0dafd4a7e68c2b0480e50e650",
|
||||
"c0213d97938af52cc29960381c77e608",
|
||||
"tools/flex-bison/windows/m4.exe.sha1":
|
||||
"0e0332c889b12576458bc481f34d6142",
|
||||
"98b1183972580437dffe690b29915c09",
|
||||
"tools/flex-bison/windows/msys-2.0.dll.sha1":
|
||||
"59854139bd445e5193812e2b910dc7b5",
|
||||
"8f76dc025488db997861057d7283ce20",
|
||||
"tools/flex-bison/windows/msys-iconv-2.dll.sha1":
|
||||
"5da154b537d340991bb4cd06eca6d523",
|
||||
"3892b2095dbfca5a71a30ffc7c895dad",
|
||||
"tools/flex-bison/windows/msys-intl-8.dll.sha1":
|
||||
"3b5cd216061b9dff4d2ae3956bc344a8"
|
||||
"ff2f3d05584d43fbd77d6251988b83ac"
|
||||
}
|
|
@ -10,23 +10,23 @@
|
|||
"src/compiler/translator/glslang_lex_autogen.cpp":
|
||||
"a645db46c3218dda37e5391e187797a2",
|
||||
"src/compiler/translator/glslang_tab_autogen.cpp":
|
||||
"3831458caec0f05cfb4948653ec74f94",
|
||||
"9719a04ebc96f86619ef474678c6a878",
|
||||
"src/compiler/translator/glslang_tab_autogen.h":
|
||||
"62ec4be0bf5b1e8d6a1653ab194d0bf4",
|
||||
"028bdaebf359aefbcdaafae466993ebe",
|
||||
"tools/flex-bison/linux/bison.sha1":
|
||||
"efa86001f00e7bcfdbe899dd15fc88e0",
|
||||
"6eba651f1769883db395dd4e485ba838",
|
||||
"tools/flex-bison/linux/flex.sha1":
|
||||
"3e73ddbd801cf3e8ed759c49572c8bf2",
|
||||
"tools/flex-bison/windows/bison.exe.sha1":
|
||||
"ad6345f2fbf1112bae67f0d54a92e574",
|
||||
"fd6d2461a2c256179faca7f5f142e689",
|
||||
"tools/flex-bison/windows/flex.exe.sha1":
|
||||
"45668fa0dafd4a7e68c2b0480e50e650",
|
||||
"c0213d97938af52cc29960381c77e608",
|
||||
"tools/flex-bison/windows/m4.exe.sha1":
|
||||
"0e0332c889b12576458bc481f34d6142",
|
||||
"98b1183972580437dffe690b29915c09",
|
||||
"tools/flex-bison/windows/msys-2.0.dll.sha1":
|
||||
"59854139bd445e5193812e2b910dc7b5",
|
||||
"8f76dc025488db997861057d7283ce20",
|
||||
"tools/flex-bison/windows/msys-iconv-2.dll.sha1":
|
||||
"5da154b537d340991bb4cd06eca6d523",
|
||||
"3892b2095dbfca5a71a30ffc7c895dad",
|
||||
"tools/flex-bison/windows/msys-intl-8.dll.sha1":
|
||||
"3b5cd216061b9dff4d2ae3956bc344a8"
|
||||
"ff2f3d05584d43fbd77d6251988b83ac"
|
||||
}
|
|
@ -84,8 +84,8 @@ struct Context
|
|||
} // namespace
|
||||
%}
|
||||
|
||||
%pure-parser
|
||||
%name-prefix "pp"
|
||||
%define api.pure
|
||||
%define api.prefix {pp}
|
||||
%parse-param {Context *context}
|
||||
%lex-param {Context *context}
|
||||
|
||||
|
|
|
@ -902,8 +902,7 @@ static int input(yyscan_t yyscanner);
|
|||
do \
|
||||
{ \
|
||||
if (fwrite(yytext, (size_t)yyleng, 1, yyout)) \
|
||||
{ \
|
||||
} \
|
||||
{} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
@ -1087,7 +1086,10 @@ YY_DECL
|
|||
/* Line breaks are just counted - not returned. */
|
||||
/* The comment is replaced by a single space. */
|
||||
case 2:
|
||||
YY_RULE_SETUP { BEGIN(COMMENT); }
|
||||
YY_RULE_SETUP
|
||||
{
|
||||
BEGIN(COMMENT);
|
||||
}
|
||||
YY_BREAK
|
||||
case 3:
|
||||
YY_RULE_SETUP
|
||||
|
@ -1310,7 +1312,10 @@ YY_DECL
|
|||
}
|
||||
YY_BREAK
|
||||
case 34:
|
||||
YY_RULE_SETUP { yyextra->leadingSpace = true; }
|
||||
YY_RULE_SETUP
|
||||
{
|
||||
yyextra->leadingSpace = true;
|
||||
}
|
||||
YY_BREAK
|
||||
case 35:
|
||||
/* rule 35 can match eol */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,8 +1,8 @@
|
|||
/* A Bison parser, made by GNU Bison 3.3.2. */
|
||||
/* A Bison parser, made by GNU Bison 3.8.2. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -16,7 +16,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, see <http://www.gnu.org/licenses/>. */
|
||||
along with this program. If not, see <https://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
|
||||
|
@ -31,8 +31,9 @@
|
|||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them. */
|
||||
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
||||
especially those whose name start with YY_ or yy_. They are
|
||||
private implementation details that can be changed or removed. */
|
||||
|
||||
#ifndef YY_YY_GLSLANG_TAB_AUTOGEN_H_INCLUDED
|
||||
#define YY_YY_GLSLANG_TAB_AUTOGEN_H_INCLUDED
|
||||
|
@ -49,199 +50,203 @@ extern int yydebug;
|
|||
#define YYLTYPE_IS_DECLARED 1
|
||||
#define YYLTYPE_IS_TRIVIAL 1
|
||||
|
||||
/* Token type. */
|
||||
/* Token kinds. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
enum yytokentype
|
||||
{
|
||||
INVARIANT = 258,
|
||||
PRECISE = 259,
|
||||
HIGH_PRECISION = 260,
|
||||
MEDIUM_PRECISION = 261,
|
||||
LOW_PRECISION = 262,
|
||||
PRECISION = 263,
|
||||
ATTRIBUTE = 264,
|
||||
CONST_QUAL = 265,
|
||||
BOOL_TYPE = 266,
|
||||
FLOAT_TYPE = 267,
|
||||
INT_TYPE = 268,
|
||||
UINT_TYPE = 269,
|
||||
BREAK = 270,
|
||||
CONTINUE = 271,
|
||||
DO = 272,
|
||||
ELSE = 273,
|
||||
FOR = 274,
|
||||
IF = 275,
|
||||
DISCARD = 276,
|
||||
RETURN = 277,
|
||||
SWITCH = 278,
|
||||
CASE = 279,
|
||||
DEFAULT = 280,
|
||||
BVEC2 = 281,
|
||||
BVEC3 = 282,
|
||||
BVEC4 = 283,
|
||||
IVEC2 = 284,
|
||||
IVEC3 = 285,
|
||||
IVEC4 = 286,
|
||||
VEC2 = 287,
|
||||
VEC3 = 288,
|
||||
VEC4 = 289,
|
||||
UVEC2 = 290,
|
||||
UVEC3 = 291,
|
||||
UVEC4 = 292,
|
||||
MATRIX2 = 293,
|
||||
MATRIX3 = 294,
|
||||
MATRIX4 = 295,
|
||||
IN_QUAL = 296,
|
||||
OUT_QUAL = 297,
|
||||
INOUT_QUAL = 298,
|
||||
UNIFORM = 299,
|
||||
BUFFER = 300,
|
||||
VARYING = 301,
|
||||
MATRIX2x3 = 302,
|
||||
MATRIX3x2 = 303,
|
||||
MATRIX2x4 = 304,
|
||||
MATRIX4x2 = 305,
|
||||
MATRIX3x4 = 306,
|
||||
MATRIX4x3 = 307,
|
||||
SAMPLE = 308,
|
||||
CENTROID = 309,
|
||||
FLAT = 310,
|
||||
SMOOTH = 311,
|
||||
NOPERSPECTIVE = 312,
|
||||
PATCH = 313,
|
||||
READONLY = 314,
|
||||
WRITEONLY = 315,
|
||||
COHERENT = 316,
|
||||
RESTRICT = 317,
|
||||
VOLATILE = 318,
|
||||
SHARED = 319,
|
||||
STRUCT = 320,
|
||||
VOID_TYPE = 321,
|
||||
WHILE = 322,
|
||||
SAMPLER2D = 323,
|
||||
SAMPLERCUBE = 324,
|
||||
SAMPLER_EXTERNAL_OES = 325,
|
||||
SAMPLER2DRECT = 326,
|
||||
SAMPLER2DARRAY = 327,
|
||||
ISAMPLER2D = 328,
|
||||
ISAMPLER3D = 329,
|
||||
ISAMPLERCUBE = 330,
|
||||
ISAMPLER2DARRAY = 331,
|
||||
USAMPLER2D = 332,
|
||||
USAMPLER3D = 333,
|
||||
USAMPLERCUBE = 334,
|
||||
USAMPLER2DARRAY = 335,
|
||||
SAMPLER2DMS = 336,
|
||||
ISAMPLER2DMS = 337,
|
||||
USAMPLER2DMS = 338,
|
||||
SAMPLER2DMSARRAY = 339,
|
||||
ISAMPLER2DMSARRAY = 340,
|
||||
USAMPLER2DMSARRAY = 341,
|
||||
SAMPLER3D = 342,
|
||||
SAMPLER3DRECT = 343,
|
||||
SAMPLER2DSHADOW = 344,
|
||||
SAMPLERCUBESHADOW = 345,
|
||||
SAMPLER2DARRAYSHADOW = 346,
|
||||
SAMPLERVIDEOWEBGL = 347,
|
||||
SAMPLERCUBEARRAYOES = 348,
|
||||
SAMPLERCUBEARRAYSHADOWOES = 349,
|
||||
ISAMPLERCUBEARRAYOES = 350,
|
||||
USAMPLERCUBEARRAYOES = 351,
|
||||
SAMPLERCUBEARRAYEXT = 352,
|
||||
SAMPLERCUBEARRAYSHADOWEXT = 353,
|
||||
ISAMPLERCUBEARRAYEXT = 354,
|
||||
USAMPLERCUBEARRAYEXT = 355,
|
||||
SAMPLERBUFFER = 356,
|
||||
ISAMPLERBUFFER = 357,
|
||||
USAMPLERBUFFER = 358,
|
||||
SAMPLEREXTERNAL2DY2YEXT = 359,
|
||||
IMAGE2D = 360,
|
||||
IIMAGE2D = 361,
|
||||
UIMAGE2D = 362,
|
||||
IMAGE3D = 363,
|
||||
IIMAGE3D = 364,
|
||||
UIMAGE3D = 365,
|
||||
IMAGE2DARRAY = 366,
|
||||
IIMAGE2DARRAY = 367,
|
||||
UIMAGE2DARRAY = 368,
|
||||
IMAGECUBE = 369,
|
||||
IIMAGECUBE = 370,
|
||||
UIMAGECUBE = 371,
|
||||
IMAGECUBEARRAYOES = 372,
|
||||
IIMAGECUBEARRAYOES = 373,
|
||||
UIMAGECUBEARRAYOES = 374,
|
||||
IMAGECUBEARRAYEXT = 375,
|
||||
IIMAGECUBEARRAYEXT = 376,
|
||||
UIMAGECUBEARRAYEXT = 377,
|
||||
IMAGEBUFFER = 378,
|
||||
IIMAGEBUFFER = 379,
|
||||
UIMAGEBUFFER = 380,
|
||||
ATOMICUINT = 381,
|
||||
PIXELLOCALANGLE = 382,
|
||||
IPIXELLOCALANGLE = 383,
|
||||
UPIXELLOCALANGLE = 384,
|
||||
LAYOUT = 385,
|
||||
YUVCSCSTANDARDEXT = 386,
|
||||
YUVCSCSTANDARDEXTCONSTANT = 387,
|
||||
IDENTIFIER = 388,
|
||||
TYPE_NAME = 389,
|
||||
FLOATCONSTANT = 390,
|
||||
INTCONSTANT = 391,
|
||||
UINTCONSTANT = 392,
|
||||
BOOLCONSTANT = 393,
|
||||
FIELD_SELECTION = 394,
|
||||
LEFT_OP = 395,
|
||||
RIGHT_OP = 396,
|
||||
INC_OP = 397,
|
||||
DEC_OP = 398,
|
||||
LE_OP = 399,
|
||||
GE_OP = 400,
|
||||
EQ_OP = 401,
|
||||
NE_OP = 402,
|
||||
AND_OP = 403,
|
||||
OR_OP = 404,
|
||||
XOR_OP = 405,
|
||||
MUL_ASSIGN = 406,
|
||||
DIV_ASSIGN = 407,
|
||||
ADD_ASSIGN = 408,
|
||||
MOD_ASSIGN = 409,
|
||||
LEFT_ASSIGN = 410,
|
||||
RIGHT_ASSIGN = 411,
|
||||
AND_ASSIGN = 412,
|
||||
XOR_ASSIGN = 413,
|
||||
OR_ASSIGN = 414,
|
||||
SUB_ASSIGN = 415,
|
||||
LEFT_PAREN = 416,
|
||||
RIGHT_PAREN = 417,
|
||||
LEFT_BRACKET = 418,
|
||||
RIGHT_BRACKET = 419,
|
||||
LEFT_BRACE = 420,
|
||||
RIGHT_BRACE = 421,
|
||||
DOT = 422,
|
||||
COMMA = 423,
|
||||
COLON = 424,
|
||||
EQUAL = 425,
|
||||
SEMICOLON = 426,
|
||||
BANG = 427,
|
||||
DASH = 428,
|
||||
TILDE = 429,
|
||||
PLUS = 430,
|
||||
STAR = 431,
|
||||
SLASH = 432,
|
||||
PERCENT = 433,
|
||||
LEFT_ANGLE = 434,
|
||||
RIGHT_ANGLE = 435,
|
||||
VERTICAL_BAR = 436,
|
||||
CARET = 437,
|
||||
AMPERSAND = 438,
|
||||
QUESTION = 439
|
||||
YYEMPTY = -2,
|
||||
YYEOF = 0, /* "end of file" */
|
||||
YYerror = 256, /* error */
|
||||
YYUNDEF = 257, /* "invalid token" */
|
||||
INVARIANT = 258, /* INVARIANT */
|
||||
PRECISE = 259, /* PRECISE */
|
||||
HIGH_PRECISION = 260, /* HIGH_PRECISION */
|
||||
MEDIUM_PRECISION = 261, /* MEDIUM_PRECISION */
|
||||
LOW_PRECISION = 262, /* LOW_PRECISION */
|
||||
PRECISION = 263, /* PRECISION */
|
||||
ATTRIBUTE = 264, /* ATTRIBUTE */
|
||||
CONST_QUAL = 265, /* CONST_QUAL */
|
||||
BOOL_TYPE = 266, /* BOOL_TYPE */
|
||||
FLOAT_TYPE = 267, /* FLOAT_TYPE */
|
||||
INT_TYPE = 268, /* INT_TYPE */
|
||||
UINT_TYPE = 269, /* UINT_TYPE */
|
||||
BREAK = 270, /* BREAK */
|
||||
CONTINUE = 271, /* CONTINUE */
|
||||
DO = 272, /* DO */
|
||||
ELSE = 273, /* ELSE */
|
||||
FOR = 274, /* FOR */
|
||||
IF = 275, /* IF */
|
||||
DISCARD = 276, /* DISCARD */
|
||||
RETURN = 277, /* RETURN */
|
||||
SWITCH = 278, /* SWITCH */
|
||||
CASE = 279, /* CASE */
|
||||
DEFAULT = 280, /* DEFAULT */
|
||||
BVEC2 = 281, /* BVEC2 */
|
||||
BVEC3 = 282, /* BVEC3 */
|
||||
BVEC4 = 283, /* BVEC4 */
|
||||
IVEC2 = 284, /* IVEC2 */
|
||||
IVEC3 = 285, /* IVEC3 */
|
||||
IVEC4 = 286, /* IVEC4 */
|
||||
VEC2 = 287, /* VEC2 */
|
||||
VEC3 = 288, /* VEC3 */
|
||||
VEC4 = 289, /* VEC4 */
|
||||
UVEC2 = 290, /* UVEC2 */
|
||||
UVEC3 = 291, /* UVEC3 */
|
||||
UVEC4 = 292, /* UVEC4 */
|
||||
MATRIX2 = 293, /* MATRIX2 */
|
||||
MATRIX3 = 294, /* MATRIX3 */
|
||||
MATRIX4 = 295, /* MATRIX4 */
|
||||
IN_QUAL = 296, /* IN_QUAL */
|
||||
OUT_QUAL = 297, /* OUT_QUAL */
|
||||
INOUT_QUAL = 298, /* INOUT_QUAL */
|
||||
UNIFORM = 299, /* UNIFORM */
|
||||
BUFFER = 300, /* BUFFER */
|
||||
VARYING = 301, /* VARYING */
|
||||
MATRIX2x3 = 302, /* MATRIX2x3 */
|
||||
MATRIX3x2 = 303, /* MATRIX3x2 */
|
||||
MATRIX2x4 = 304, /* MATRIX2x4 */
|
||||
MATRIX4x2 = 305, /* MATRIX4x2 */
|
||||
MATRIX3x4 = 306, /* MATRIX3x4 */
|
||||
MATRIX4x3 = 307, /* MATRIX4x3 */
|
||||
SAMPLE = 308, /* SAMPLE */
|
||||
CENTROID = 309, /* CENTROID */
|
||||
FLAT = 310, /* FLAT */
|
||||
SMOOTH = 311, /* SMOOTH */
|
||||
NOPERSPECTIVE = 312, /* NOPERSPECTIVE */
|
||||
PATCH = 313, /* PATCH */
|
||||
READONLY = 314, /* READONLY */
|
||||
WRITEONLY = 315, /* WRITEONLY */
|
||||
COHERENT = 316, /* COHERENT */
|
||||
RESTRICT = 317, /* RESTRICT */
|
||||
VOLATILE = 318, /* VOLATILE */
|
||||
SHARED = 319, /* SHARED */
|
||||
STRUCT = 320, /* STRUCT */
|
||||
VOID_TYPE = 321, /* VOID_TYPE */
|
||||
WHILE = 322, /* WHILE */
|
||||
SAMPLER2D = 323, /* SAMPLER2D */
|
||||
SAMPLERCUBE = 324, /* SAMPLERCUBE */
|
||||
SAMPLER_EXTERNAL_OES = 325, /* SAMPLER_EXTERNAL_OES */
|
||||
SAMPLER2DRECT = 326, /* SAMPLER2DRECT */
|
||||
SAMPLER2DARRAY = 327, /* SAMPLER2DARRAY */
|
||||
ISAMPLER2D = 328, /* ISAMPLER2D */
|
||||
ISAMPLER3D = 329, /* ISAMPLER3D */
|
||||
ISAMPLERCUBE = 330, /* ISAMPLERCUBE */
|
||||
ISAMPLER2DARRAY = 331, /* ISAMPLER2DARRAY */
|
||||
USAMPLER2D = 332, /* USAMPLER2D */
|
||||
USAMPLER3D = 333, /* USAMPLER3D */
|
||||
USAMPLERCUBE = 334, /* USAMPLERCUBE */
|
||||
USAMPLER2DARRAY = 335, /* USAMPLER2DARRAY */
|
||||
SAMPLER2DMS = 336, /* SAMPLER2DMS */
|
||||
ISAMPLER2DMS = 337, /* ISAMPLER2DMS */
|
||||
USAMPLER2DMS = 338, /* USAMPLER2DMS */
|
||||
SAMPLER2DMSARRAY = 339, /* SAMPLER2DMSARRAY */
|
||||
ISAMPLER2DMSARRAY = 340, /* ISAMPLER2DMSARRAY */
|
||||
USAMPLER2DMSARRAY = 341, /* USAMPLER2DMSARRAY */
|
||||
SAMPLER3D = 342, /* SAMPLER3D */
|
||||
SAMPLER3DRECT = 343, /* SAMPLER3DRECT */
|
||||
SAMPLER2DSHADOW = 344, /* SAMPLER2DSHADOW */
|
||||
SAMPLERCUBESHADOW = 345, /* SAMPLERCUBESHADOW */
|
||||
SAMPLER2DARRAYSHADOW = 346, /* SAMPLER2DARRAYSHADOW */
|
||||
SAMPLERVIDEOWEBGL = 347, /* SAMPLERVIDEOWEBGL */
|
||||
SAMPLERCUBEARRAYOES = 348, /* SAMPLERCUBEARRAYOES */
|
||||
SAMPLERCUBEARRAYSHADOWOES = 349, /* SAMPLERCUBEARRAYSHADOWOES */
|
||||
ISAMPLERCUBEARRAYOES = 350, /* ISAMPLERCUBEARRAYOES */
|
||||
USAMPLERCUBEARRAYOES = 351, /* USAMPLERCUBEARRAYOES */
|
||||
SAMPLERCUBEARRAYEXT = 352, /* SAMPLERCUBEARRAYEXT */
|
||||
SAMPLERCUBEARRAYSHADOWEXT = 353, /* SAMPLERCUBEARRAYSHADOWEXT */
|
||||
ISAMPLERCUBEARRAYEXT = 354, /* ISAMPLERCUBEARRAYEXT */
|
||||
USAMPLERCUBEARRAYEXT = 355, /* USAMPLERCUBEARRAYEXT */
|
||||
SAMPLERBUFFER = 356, /* SAMPLERBUFFER */
|
||||
ISAMPLERBUFFER = 357, /* ISAMPLERBUFFER */
|
||||
USAMPLERBUFFER = 358, /* USAMPLERBUFFER */
|
||||
SAMPLEREXTERNAL2DY2YEXT = 359, /* SAMPLEREXTERNAL2DY2YEXT */
|
||||
IMAGE2D = 360, /* IMAGE2D */
|
||||
IIMAGE2D = 361, /* IIMAGE2D */
|
||||
UIMAGE2D = 362, /* UIMAGE2D */
|
||||
IMAGE3D = 363, /* IMAGE3D */
|
||||
IIMAGE3D = 364, /* IIMAGE3D */
|
||||
UIMAGE3D = 365, /* UIMAGE3D */
|
||||
IMAGE2DARRAY = 366, /* IMAGE2DARRAY */
|
||||
IIMAGE2DARRAY = 367, /* IIMAGE2DARRAY */
|
||||
UIMAGE2DARRAY = 368, /* UIMAGE2DARRAY */
|
||||
IMAGECUBE = 369, /* IMAGECUBE */
|
||||
IIMAGECUBE = 370, /* IIMAGECUBE */
|
||||
UIMAGECUBE = 371, /* UIMAGECUBE */
|
||||
IMAGECUBEARRAYOES = 372, /* IMAGECUBEARRAYOES */
|
||||
IIMAGECUBEARRAYOES = 373, /* IIMAGECUBEARRAYOES */
|
||||
UIMAGECUBEARRAYOES = 374, /* UIMAGECUBEARRAYOES */
|
||||
IMAGECUBEARRAYEXT = 375, /* IMAGECUBEARRAYEXT */
|
||||
IIMAGECUBEARRAYEXT = 376, /* IIMAGECUBEARRAYEXT */
|
||||
UIMAGECUBEARRAYEXT = 377, /* UIMAGECUBEARRAYEXT */
|
||||
IMAGEBUFFER = 378, /* IMAGEBUFFER */
|
||||
IIMAGEBUFFER = 379, /* IIMAGEBUFFER */
|
||||
UIMAGEBUFFER = 380, /* UIMAGEBUFFER */
|
||||
ATOMICUINT = 381, /* ATOMICUINT */
|
||||
PIXELLOCALANGLE = 382, /* PIXELLOCALANGLE */
|
||||
IPIXELLOCALANGLE = 383, /* IPIXELLOCALANGLE */
|
||||
UPIXELLOCALANGLE = 384, /* UPIXELLOCALANGLE */
|
||||
LAYOUT = 385, /* LAYOUT */
|
||||
YUVCSCSTANDARDEXT = 386, /* YUVCSCSTANDARDEXT */
|
||||
YUVCSCSTANDARDEXTCONSTANT = 387, /* YUVCSCSTANDARDEXTCONSTANT */
|
||||
IDENTIFIER = 388, /* IDENTIFIER */
|
||||
TYPE_NAME = 389, /* TYPE_NAME */
|
||||
FLOATCONSTANT = 390, /* FLOATCONSTANT */
|
||||
INTCONSTANT = 391, /* INTCONSTANT */
|
||||
UINTCONSTANT = 392, /* UINTCONSTANT */
|
||||
BOOLCONSTANT = 393, /* BOOLCONSTANT */
|
||||
FIELD_SELECTION = 394, /* FIELD_SELECTION */
|
||||
LEFT_OP = 395, /* LEFT_OP */
|
||||
RIGHT_OP = 396, /* RIGHT_OP */
|
||||
INC_OP = 397, /* INC_OP */
|
||||
DEC_OP = 398, /* DEC_OP */
|
||||
LE_OP = 399, /* LE_OP */
|
||||
GE_OP = 400, /* GE_OP */
|
||||
EQ_OP = 401, /* EQ_OP */
|
||||
NE_OP = 402, /* NE_OP */
|
||||
AND_OP = 403, /* AND_OP */
|
||||
OR_OP = 404, /* OR_OP */
|
||||
XOR_OP = 405, /* XOR_OP */
|
||||
MUL_ASSIGN = 406, /* MUL_ASSIGN */
|
||||
DIV_ASSIGN = 407, /* DIV_ASSIGN */
|
||||
ADD_ASSIGN = 408, /* ADD_ASSIGN */
|
||||
MOD_ASSIGN = 409, /* MOD_ASSIGN */
|
||||
LEFT_ASSIGN = 410, /* LEFT_ASSIGN */
|
||||
RIGHT_ASSIGN = 411, /* RIGHT_ASSIGN */
|
||||
AND_ASSIGN = 412, /* AND_ASSIGN */
|
||||
XOR_ASSIGN = 413, /* XOR_ASSIGN */
|
||||
OR_ASSIGN = 414, /* OR_ASSIGN */
|
||||
SUB_ASSIGN = 415, /* SUB_ASSIGN */
|
||||
LEFT_PAREN = 416, /* LEFT_PAREN */
|
||||
RIGHT_PAREN = 417, /* RIGHT_PAREN */
|
||||
LEFT_BRACKET = 418, /* LEFT_BRACKET */
|
||||
RIGHT_BRACKET = 419, /* RIGHT_BRACKET */
|
||||
LEFT_BRACE = 420, /* LEFT_BRACE */
|
||||
RIGHT_BRACE = 421, /* RIGHT_BRACE */
|
||||
DOT = 422, /* DOT */
|
||||
COMMA = 423, /* COMMA */
|
||||
COLON = 424, /* COLON */
|
||||
EQUAL = 425, /* EQUAL */
|
||||
SEMICOLON = 426, /* SEMICOLON */
|
||||
BANG = 427, /* BANG */
|
||||
DASH = 428, /* DASH */
|
||||
TILDE = 429, /* TILDE */
|
||||
PLUS = 430, /* PLUS */
|
||||
STAR = 431, /* STAR */
|
||||
SLASH = 432, /* SLASH */
|
||||
PERCENT = 433, /* PERCENT */
|
||||
LEFT_ANGLE = 434, /* LEFT_ANGLE */
|
||||
RIGHT_ANGLE = 435, /* RIGHT_ANGLE */
|
||||
VERTICAL_BAR = 436, /* VERTICAL_BAR */
|
||||
CARET = 437, /* CARET */
|
||||
AMPERSAND = 438, /* AMPERSAND */
|
||||
QUESTION = 439 /* QUESTION */
|
||||
};
|
||||
typedef enum yytokentype yytoken_kind_t;
|
||||
#endif
|
||||
|
||||
/* Value type. */
|
||||
#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
|
||||
|
@ -291,7 +296,6 @@ union YYSTYPE
|
|||
};
|
||||
} interm;
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
|
|
|
@ -33,7 +33,9 @@ def get_exe_name(file_name, windows_extension):
|
|||
|
||||
|
||||
def upload_to_google_storage(bucket, files):
|
||||
upload_script = find_file_in_path('upload_to_google_storage.py')
|
||||
file_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
upload_script = os.path.join(file_dir, '..', 'third_party', 'depot_tools',
|
||||
'upload_to_google_storage.py')
|
||||
upload_args = ['python', upload_script, '-b', bucket] + files
|
||||
return subprocess.call(upload_args) == 0
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@ review process. You will also want to run
|
|||
[`scripts/run_code_generation.py`](../../scripts/run_code_generation.py) to
|
||||
update the generated files.
|
||||
|
||||
Please update both Windows and Linux binaries at the same time. Use two CLs. One
|
||||
for each platform. Note that we don't currently support Mac for generating the
|
||||
lexer and parser files. If we do we should add a flex/bison download for Mac as
|
||||
well.
|
||||
Please update both Windows and Linux binaries at the same time. Start with
|
||||
Windows, then merge your work into a single CL that updates both binaries
|
||||
simultaneously. Note that we don't currently support Mac for generating the
|
||||
lexer and parser files. If we do we should add a flex/bison download for Mac
|
||||
as well.
|
||||
|
||||
Contact jmadill or syoussefi for any help with updating the binaries.
|
||||
|
||||
|
@ -34,7 +35,7 @@ already be installed. Install bison:
|
|||
$ pacman -S bison
|
||||
```
|
||||
|
||||
Note the versions of flex and bison so the same versions can be build on Linux.
|
||||
Note the versions of flex and bison, so you can build the exact same versions on Linux.
|
||||
For example:
|
||||
|
||||
```
|
||||
|
@ -42,10 +43,10 @@ $ flex --version
|
|||
flex 2.6.4
|
||||
|
||||
$ bison --version
|
||||
bison (GNU Bison) 3.3.2
|
||||
bison (GNU Bison) 3.8.2
|
||||
```
|
||||
|
||||
The only dependencies from MSys2 should be the following:
|
||||
The only dependencies outside /Windows/ from MSys2 should be the following:
|
||||
|
||||
```
|
||||
msys-intl-8.dll
|
||||
|
@ -79,7 +80,7 @@ Upload the binaries:
|
|||
|
||||
```
|
||||
$ cd angle/
|
||||
$ python tools/flex-bison/update_flex_bison_binaries.py
|
||||
$ py tools/flex-bison/update_flex_bison_binaries.py
|
||||
```
|
||||
|
||||
### On Linux
|
||||
|
@ -99,8 +100,8 @@ $ make -j
|
|||
|
||||
```
|
||||
# Get the source of bison
|
||||
$ curl http://ftp.gnu.org/gnu/bison/bison-3.3.2.tar.xz | tar -xJ
|
||||
$ cd bison-3.3.2
|
||||
$ curl http://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz | tar -xJ
|
||||
$ cd bison-3.8.2
|
||||
# Build
|
||||
$ mkdir build && cd build
|
||||
$ ../configure CFLAGS="-O2"
|
||||
|
@ -123,7 +124,7 @@ Upload the binaries:
|
|||
|
||||
```
|
||||
$ cd angle/
|
||||
$ python tools/flex-bison/update_flex_bison_binaries.py
|
||||
$ ./tools/flex-bison/update_flex_bison_binaries.py
|
||||
```
|
||||
|
||||
[Bison]: https://www.gnu.org/software/bison/
|
||||
|
|
|
@ -1 +1 @@
|
|||
e628b73cd0a767d93e1f94b5a86ce51ca83c99d5
|
||||
ecf11699b180eb967b8c4d08011b5704a445adeb
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Language-independent M4 Macros for Bison.
|
||||
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation,
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2021 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
@ -16,7 +16,30 @@
|
|||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
# m4_gsub(STRING, RE1, SUBST1, RE2, SUBST2, ...)
|
||||
# ----------------------------------------------
|
||||
# m4 equivalent of
|
||||
#
|
||||
# $_ = STRING;
|
||||
# s/RE1/SUBST1/g;
|
||||
# s/RE2/SUBST2/g;
|
||||
# ...
|
||||
#
|
||||
# Really similar to m4_bpatsubsts, but behaves properly with quotes.
|
||||
# See m4.at's "Generating Comments". Super inelegant, but so far, I
|
||||
# did not find any better solution.
|
||||
m4_define([b4_gsub],
|
||||
[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst([[[[$1]]]],
|
||||
[$2], [$3]),
|
||||
[$4], [$5]),
|
||||
[$6], [$7])])
|
||||
|
||||
# m4_shift2 and m4_shift3 are provided by m4sugar.
|
||||
m4_define([m4_shift4], [m4_shift(m4_shift(m4_shift(m4_shift($@))))])
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
|
@ -26,7 +49,7 @@
|
|||
# b4_generated_by
|
||||
# ---------------
|
||||
m4_define([b4_generated_by],
|
||||
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
|
||||
[b4_comment([A Bison parser, made by GNU Bison b4_version_string.])
|
||||
])
|
||||
|
||||
# b4_copyright(TITLE, [YEARS])
|
||||
|
@ -51,7 +74,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||
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, see <http://www.gnu.org/licenses/>.])
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.])
|
||||
|
||||
b4_comment([As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
|
@ -72,8 +95,9 @@ version 2.2 of Bison.])
|
|||
# -------------
|
||||
# Issue a warning about private implementation details.
|
||||
m4_define([b4_disclaimer],
|
||||
[b4_comment([Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them.])
|
||||
[b4_comment([DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
||||
especially those whose name start with YY_ or yy_. They are
|
||||
private implementation details that can be changed or removed.])
|
||||
])
|
||||
|
||||
|
||||
|
@ -161,7 +185,7 @@ m4_define([b4_error],
|
|||
[b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl
|
||||
[m4_if([$#], [4], [],
|
||||
[m4_foreach([b4_arg],
|
||||
m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),
|
||||
m4_dquote(m4_shift4($@)),
|
||||
[[@,]b4_arg])])[@)]])])
|
||||
|
||||
# b4_warn(FORMAT, [ARG1], [ARG2], ...)
|
||||
|
@ -192,7 +216,7 @@ m4_define([b4_error],
|
|||
# @warn(1@)
|
||||
# @warn(1@,2@)
|
||||
m4_define([b4_warn],
|
||||
[b4_error([[warn]], [], [], $@)])
|
||||
[b4_warn_at([], [], $@)])
|
||||
|
||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# ---------------------------------------------------
|
||||
|
@ -210,7 +234,7 @@ m4_define([b4_warn_at],
|
|||
#
|
||||
# See b4_warn example.
|
||||
m4_define([b4_complain],
|
||||
[b4_error([[complain]], [], [], $@)])
|
||||
[b4_complain_at([], [], $@)])
|
||||
|
||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# -------------------------------------------------------
|
||||
|
@ -226,8 +250,7 @@ m4_define([b4_complain_at],
|
|||
#
|
||||
# See b4_warn example.
|
||||
m4_define([b4_fatal],
|
||||
[b4_error([[fatal]], [], [], $@)dnl
|
||||
m4_exit(1)])
|
||||
[b4_fatal_at([], [], $@)])
|
||||
|
||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||
# ----------------------------------------------------
|
||||
|
@ -238,6 +261,13 @@ m4_define([b4_fatal_at],
|
|||
[b4_error([[fatal]], $@)dnl
|
||||
m4_exit(1)])
|
||||
|
||||
# b4_canary(MSG)
|
||||
# --------------
|
||||
# Issue a warning on stderr and in the output. Used in the test suite
|
||||
# to catch spurious m4 evaluations.
|
||||
m4_define([b4_canary],
|
||||
[m4_errprintn([dead canary: $1])DEAD CANARY($1)])
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data Types. ##
|
||||
|
@ -309,14 +339,14 @@ number is the opposite. If YYTABLE_NINF, syntax error.]])
|
|||
$1([check], [b4_check])
|
||||
|
||||
$1([stos], [b4_stos],
|
||||
[[YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
||||
symbol of state STATE-NUM.]])
|
||||
[[YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
|
||||
state STATE-NUM.]])
|
||||
|
||||
$1([r1], [b4_r1],
|
||||
[[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]])
|
||||
[[YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.]])
|
||||
|
||||
$1([r2], [b4_r2],
|
||||
[[YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.]])
|
||||
[[YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.]])
|
||||
])
|
||||
|
||||
|
||||
|
@ -368,8 +398,9 @@ m4_define([b4_$3_if],
|
|||
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
||||
# -----------------------------
|
||||
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
||||
b4_define_flag_if([has_translations]) # Whether some tokens are internationalized.
|
||||
b4_define_flag_if([header]) # Whether a header is requested.
|
||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||
|
@ -380,43 +411,100 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
|||
m4_define([b4_glr_cc_if],
|
||||
[m4_if(b4_skeleton, ["glr.cc"], $@)])
|
||||
|
||||
# b4_glr2_cc_if([IF-TRUE], [IF-FALSE])
|
||||
# ------------------------------------
|
||||
m4_define([b4_glr2_cc_if],
|
||||
[m4_if(b4_skeleton, ["glr2.cc"], $@)])
|
||||
|
||||
## --------- ##
|
||||
## Symbols. ##
|
||||
## --------- ##
|
||||
|
||||
# For a description of the Symbol handling, see README.
|
||||
# For a description of the Symbol handling, see README.md.
|
||||
#
|
||||
# The following macros provide access to symbol related values.
|
||||
|
||||
# __b4_symbol(NUM, FIELD)
|
||||
# -----------------------
|
||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||
# undefined.
|
||||
# Fetch FIELD of symbol #NUM. Fail if undefined.
|
||||
m4_define([__b4_symbol],
|
||||
[m4_indir([b4_symbol($1, $2)])])
|
||||
|
||||
|
||||
# _b4_symbol(NUM, FIELD)
|
||||
# ----------------------
|
||||
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||
# undefined.
|
||||
# Fetch FIELD of symbol #NUM (or "orig NUM", see README.md).
|
||||
# Fail if undefined.
|
||||
m4_define([_b4_symbol],
|
||||
[m4_ifdef([b4_symbol($1, number)],
|
||||
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
|
||||
[__b4_symbol([$1], [$2])])])
|
||||
|
||||
|
||||
# b4_symbol_token_kind(NUM)
|
||||
# -------------------------
|
||||
# The token kind of this symbol.
|
||||
m4_define([b4_symbol_token_kind],
|
||||
[b4_percent_define_get([api.token.prefix])dnl
|
||||
_b4_symbol([$1], [id])])
|
||||
|
||||
|
||||
# b4_symbol_kind_base(NUM)
|
||||
# ------------------------
|
||||
# Build the name of the kind of this symbol. It must always exist,
|
||||
# otherwise some symbols might not be represented in the enum, which
|
||||
# might be compiled into too small a type to contain all the symbol
|
||||
# numbers.
|
||||
m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])])
|
||||
m4_define([b4_symbol_kind_base],
|
||||
[b4_percent_define_get([api.symbol.prefix])dnl
|
||||
m4_case([$1],
|
||||
[-2], [[YYEMPTY]],
|
||||
[0], [[YYEOF]],
|
||||
[1], [[YYerror]],
|
||||
[2], [[YYUNDEF]],
|
||||
[m4_case(b4_symbol([$1], [tag]),
|
||||
[$accept], [[YYACCEPT]],
|
||||
[b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]),
|
||||
[m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])])
|
||||
|
||||
|
||||
# b4_symbol_kind(NUM)
|
||||
# -------------------
|
||||
# Same as b4_symbol_kind, but possibly with a prefix in some
|
||||
# languages. E.g., EOF's kind_base and kind are YYSYMBOL_YYEOF in C,
|
||||
# but are S_YYEMPTY and symbol_kind::S_YYEMPTY in C++.
|
||||
m4_copy([b4_symbol_kind_base], [b4_symbol_kind])
|
||||
|
||||
|
||||
# b4_symbol_slot(NUM)
|
||||
# -------------------
|
||||
# The name of union member that contains the value of these symbols.
|
||||
# Currently, we are messy, this should actually be type_tag, but type_tag
|
||||
# has several meanings.
|
||||
m4_define([b4_symbol_slot],
|
||||
[m4_case(b4_percent_define_get([[api.value.type]]),
|
||||
[union], [b4_symbol([$1], [type_tag])],
|
||||
[variant], [b4_symbol([$1], [type_tag])],
|
||||
[b4_symbol([$1], [type])])])
|
||||
|
||||
|
||||
# b4_symbol(NUM, FIELD)
|
||||
# ---------------------
|
||||
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
|
||||
# undefined. If FIELD = id, prepend the token prefix.
|
||||
# Fetch FIELD of symbol #NUM (or "orig NUM", or "empty"). Fail if undefined.
|
||||
#
|
||||
# If FIELD = id, prepend the token prefix.
|
||||
m4_define([b4_symbol],
|
||||
[m4_case([$2],
|
||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
||||
[_b4_symbol([$1], [id])])],
|
||||
[_b4_symbol($@)])])
|
||||
[m4_if([$1], [empty], [b4_symbol([-2], [$2])],
|
||||
[$1], [eof], [b4_symbol([0], [$2])],
|
||||
[$1], [error], [b4_symbol([1], [$2])],
|
||||
[$1], [undef], [b4_symbol([2], [$2])],
|
||||
[m4_case([$2],
|
||||
[id], [b4_symbol_token_kind([$1])],
|
||||
[kind_base], [b4_symbol_kind_base([$1])],
|
||||
[kind], [b4_symbol_kind([$1])],
|
||||
[slot], [b4_symbol_slot([$1])],
|
||||
[_b4_symbol($@)])])])
|
||||
|
||||
|
||||
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
|
||||
|
@ -438,16 +526,9 @@ m4_define([b4_symbol_tag_comment],
|
|||
])
|
||||
|
||||
|
||||
# b4_symbol_action_location(SYMBOL-NUM, KIND)
|
||||
# -------------------------------------------
|
||||
# Report the location of the KIND action as FILE:LINE.
|
||||
m4_define([b4_symbol_action_location],
|
||||
[b4_symbol([$1], [$2_file]):b4_syncline([b4_symbol([$1], [$2_line])])])
|
||||
|
||||
|
||||
# b4_symbol_action(SYMBOL-NUM, KIND)
|
||||
# ----------------------------------
|
||||
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
||||
# b4_symbol_action(SYMBOL-NUM, ACTION)
|
||||
# ------------------------------------
|
||||
# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
|
||||
m4_define([b4_symbol_action],
|
||||
[b4_symbol_if([$1], [has_$2],
|
||||
[b4_dollar_pushdef([(*yyvaluep)],
|
||||
|
@ -455,9 +536,9 @@ m4_define([b4_symbol_action],
|
|||
[],
|
||||
[(*yylocationp)])dnl
|
||||
_b4_symbol_case([$1])[]dnl
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;
|
||||
|
||||
b4_dollar_popdef[]dnl
|
||||
|
@ -471,21 +552,21 @@ m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])])
|
|||
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
|
||||
|
||||
|
||||
# b4_symbol_actions(KIND, [TYPE = yytype])
|
||||
# ----------------------------------------
|
||||
# Emit the symbol actions for KIND ("printer" or "destructor").
|
||||
# Dispatch on TYPE.
|
||||
# b4_symbol_actions(ACTION, [KIND = yykind])
|
||||
# ------------------------------------------
|
||||
# Emit the symbol actions for ACTION ("destructor" or "printer").
|
||||
# Dispatch on KIND.
|
||||
m4_define([b4_symbol_actions],
|
||||
[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl
|
||||
m4_ifval(m4_defn([b4_actions_]),
|
||||
[switch (m4_default([$2], [yytype]))
|
||||
[switch (m4_default([$2], [yykind]))
|
||||
{
|
||||
m4_defn([b4_actions_])[]dnl
|
||||
default:
|
||||
break;
|
||||
}dnl
|
||||
],
|
||||
[YYUSE (m4_default([$2], [yytype]));])dnl
|
||||
[b4_use(m4_default([$2], [yykind]));])dnl
|
||||
m4_popdef([b4_actions_])dnl
|
||||
])
|
||||
|
||||
|
@ -495,7 +576,7 @@ m4_popdef([b4_actions_])dnl
|
|||
# easier to use with m4_map, but then, use []dnl to suppress the last
|
||||
# one.
|
||||
m4_define([_b4_symbol_case],
|
||||
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
|
||||
[case b4_symbol([$1], [kind]): b4_symbol_tag_comment([$1])])
|
||||
])
|
||||
|
||||
|
||||
|
@ -515,13 +596,14 @@ m4_define([b4_symbol_map],
|
|||
|
||||
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
||||
# -------------------------------------------
|
||||
# Whether NUM denotes a token that has an exported definition (i.e.,
|
||||
# shows in enum yytokentype).
|
||||
# Whether NUM denotes a token kind that has an exported definition
|
||||
# (i.e., shows in enum yytokentype).
|
||||
m4_define([b4_token_visible_if],
|
||||
[b4_symbol_if([$1], [is_token],
|
||||
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
||||
[$3])])
|
||||
|
||||
|
||||
# b4_token_has_definition(NUM)
|
||||
# ----------------------------
|
||||
# 1 if NUM is visible, nothing otherwise.
|
||||
|
@ -538,13 +620,27 @@ m4_define([b4_any_token_visible_if],
|
|||
|
||||
# b4_token_format(FORMAT, NUM)
|
||||
# ----------------------------
|
||||
# If token NUM has a visible ID, format FORMAT with ID, USER_NUMBER.
|
||||
m4_define([b4_token_format],
|
||||
[b4_token_visible_if([$2],
|
||||
[m4_quote(m4_format([$1],
|
||||
[b4_symbol([$2], [id])],
|
||||
[b4_symbol([$2], [user_number])]))])])
|
||||
[m4_format([[$1]],
|
||||
b4_symbol([$2], [id]),
|
||||
b4_symbol([$2], b4_api_token_raw_if([[number]], [[code]])))])])
|
||||
|
||||
|
||||
# b4_last_enum_token
|
||||
# ------------------
|
||||
# The code of the last token visible token.
|
||||
m4_define([_b4_last_enum_token],
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_define([b4_last_enum_token], [$1])])])
|
||||
b4_symbol_foreach([_b4_last_enum_token])
|
||||
|
||||
# b4_last_symbol
|
||||
# --------------
|
||||
# The code of the last symbol.
|
||||
m4_define([b4_last_symbol], m4_eval(b4_tokens_number + b4_nterms_number - 1))
|
||||
|
||||
## ------- ##
|
||||
## Types. ##
|
||||
## ------- ##
|
||||
|
@ -566,11 +662,11 @@ m4_define([_b4_type_action],
|
|||
|
||||
])])
|
||||
|
||||
# b4_type_foreach(MACRO)
|
||||
# ----------------------
|
||||
# b4_type_foreach(MACRO, [SEP])
|
||||
# -----------------------------
|
||||
# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set.
|
||||
m4_define([b4_type_foreach],
|
||||
[m4_map([$1], m4_defn([b4_type_names]))])
|
||||
[m4_map_sep([$1], [$2], m4_defn([b4_type_names]))])
|
||||
|
||||
|
||||
|
||||
|
@ -586,12 +682,15 @@ m4_define([b4_basename],
|
|||
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
||||
|
||||
|
||||
# b4_syncline(LINE, FILE)
|
||||
# -----------------------
|
||||
# b4_syncline(LINE, FILE)dnl
|
||||
# --------------------------
|
||||
# Should always be following by a dnl.
|
||||
#
|
||||
# Emit "#line LINE FILE /* __LINE__ __FILE__ */".
|
||||
m4_define([b4_syncline],
|
||||
[b4_flag_if([synclines],
|
||||
[b4_sync_start([$1], [$2]) b4_sync_end([__line__],
|
||||
[b4_basename(m4_quote(__file__))])[]dnl
|
||||
[b4_sync_start([$1], [$2])[]dnl
|
||||
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||
])])
|
||||
|
||||
# b4_sync_start(LINE, FILE)
|
||||
|
@ -603,7 +702,17 @@ m4_define([b4_sync_start], [b4_comment([$2:$1])])
|
|||
# -----------------------
|
||||
# Syncline for the current place, which ends. Typically a comment
|
||||
# left for the reader.
|
||||
m4_define([b4_sync_end], [b4_comment([$2:$1])])
|
||||
m4_define([b4_sync_end], [ b4_comment([$2:$1])]
|
||||
)
|
||||
# This generates dependencies on the Bison skeletons hence lots of
|
||||
# useless 'git diff'. This location is useless for the regular
|
||||
# user (who does not care about the skeletons) and is actually not
|
||||
# useful for Bison developers too (I, Akim, never used this to locate
|
||||
# the code in skeletons that generated output). So disable it
|
||||
# completely. If someone thinks this was actually useful, a %define
|
||||
# variable should be provided to control the level of verbosity of
|
||||
# '#line', in replacement of --no-lines.
|
||||
m4_define([b4_sync_end])
|
||||
|
||||
|
||||
# b4_user_code(USER-CODE)
|
||||
|
@ -678,7 +787,7 @@ m4_define([b4_check_user_names],
|
|||
[m4_pushdef([b4_occurrence], b4_occurrence)dnl
|
||||
m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl
|
||||
m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl
|
||||
m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl
|
||||
m4_pushdef([b4_end], m4_shift2(b4_occurrence))dnl
|
||||
m4_ifndef($3[(]m4_quote(b4_user_name)[)],
|
||||
[b4_complain_at([b4_start], [b4_end],
|
||||
[[%s '%s' is not used]],
|
||||
|
@ -753,8 +862,10 @@ m4_define([b4_percent_define_get_kind],
|
|||
[m4_indir([b4_percent_define_kind(]$1[)])],
|
||||
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
||||
|
||||
# b4_percent_define_get_syncline(VARIABLE)
|
||||
# ----------------------------------------
|
||||
# b4_percent_define_get_syncline(VARIABLE)dnl
|
||||
# -------------------------------------------
|
||||
# Should always be following by a dnl.
|
||||
#
|
||||
# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly.
|
||||
# That is, if the %define variable VARIABLE is undefined, complain fatally
|
||||
# since that's a Bison or skeleton error. Otherwise, return its definition
|
||||
|
@ -871,15 +982,18 @@ m4_define([b4_percent_define_flag_if],
|
|||
# For example:
|
||||
#
|
||||
# b4_percent_define_default([[foo]], [[default value]])
|
||||
m4_define([_b4_percent_define_define],
|
||||
[m4_define([b4_percent_define(]$1[)], [$2])dnl
|
||||
m4_define([b4_percent_define_kind(]$1[)],
|
||||
[m4_default([$3], [keyword])])dnl
|
||||
m4_define([b4_percent_define_loc(]$1[)],
|
||||
[[[[<skeleton default value>:-1.-1]],
|
||||
[[<skeleton default value>:-1.-1]]]])dnl
|
||||
m4_define([b4_percent_define_syncline(]$1[)], [[]])])
|
||||
|
||||
m4_define([b4_percent_define_default],
|
||||
[_b4_percent_define_ifdef([$1], [],
|
||||
[m4_define([b4_percent_define(]$1[)], [$2])dnl
|
||||
m4_define([b4_percent_define_kind(]$1[)],
|
||||
[m4_default([$3], [keyword])])dnl
|
||||
m4_define([b4_percent_define_loc(]$1[)],
|
||||
[[[[<skeleton default value>:-1.-1]],
|
||||
[[<skeleton default value>:-1.-1]]]])dnl
|
||||
m4_define([b4_percent_define_syncline(]$1[)], [[]])])])
|
||||
[_b4_percent_define_define($@)])])
|
||||
|
||||
|
||||
# b4_percent_define_if_define(NAME, [VARIABLE = NAME])
|
||||
|
@ -889,11 +1003,12 @@ m4_define([b4_percent_define_default],
|
|||
# to '_'.
|
||||
m4_define([_b4_percent_define_if_define],
|
||||
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
|
||||
[b4_percent_define_flag_if(m4_default([$2], [$1]),
|
||||
[$3], [$4])])])
|
||||
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])dnl
|
||||
b4_percent_define_flag_if(m4_default([$2], [$1]),
|
||||
[$3], [$4])])])
|
||||
|
||||
m4_define([b4_percent_define_if_define],
|
||||
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])
|
||||
_b4_percent_define_if_define([$1], [$2], $[1], $[2])])
|
||||
[_b4_percent_define_if_define([$1], [$2], $[1], $[2])])
|
||||
|
||||
|
||||
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
|
||||
|
@ -968,10 +1083,9 @@ m4_define([b4_percent_code_get],
|
|||
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
||||
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
||||
m4_ifdef(b4_macro_name,
|
||||
[b4_comment([m4_if([$#], [0], [[Unqualified %code]],
|
||||
[["%code ]$1["]])[ blocks.]])
|
||||
b4_user_code([m4_indir(b4_macro_name)])
|
||||
])dnl
|
||||
[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]],
|
||||
[[["%code ]$1[" blocks.]]]))
|
||||
b4_user_code([m4_indir(b4_macro_name)])])dnl
|
||||
m4_popdef([b4_macro_name])])
|
||||
|
||||
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
||||
|
@ -995,10 +1109,12 @@ m4_define([b4_percent_code_ifdef],
|
|||
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
||||
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
||||
# ----------------------------------------------------------
|
||||
b4_percent_define_if_define([api.token.raw])
|
||||
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
||||
b4_percent_define_if_define([parse.assert])
|
||||
b4_percent_define_if_define([parse.trace])
|
||||
b4_percent_define_if_define([posix])
|
||||
|
||||
|
||||
# b4_bison_locations_if([IF-TRUE])
|
||||
|
@ -1009,31 +1125,37 @@ m4_define([b4_bison_locations_if],
|
|||
[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])])
|
||||
|
||||
|
||||
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
|
||||
|
||||
# %define parse.error "(custom|detailed|simple|verbose)"
|
||||
# ------------------------------------------------------
|
||||
# Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and
|
||||
# b4_error_verbose_flag.
|
||||
b4_percent_define_default([[parse.error]], [[simple]])
|
||||
b4_percent_define_check_values([[[[parse.error]],
|
||||
[[simple]], [[verbose]]]])
|
||||
m4_define([b4_error_verbose_flag],
|
||||
[m4_case(b4_percent_define_get([[parse.error]]),
|
||||
[simple], [[0]],
|
||||
[verbose], [[1]])])
|
||||
b4_define_flag_if([error_verbose])
|
||||
[[custom]], [[detailed]], [[simple]], [[verbose]]]])
|
||||
|
||||
# yytoken_table is needed to support verbose errors.
|
||||
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
||||
# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE)
|
||||
# ----------------------------------------------------------
|
||||
m4_define([b4_parse_error_case],
|
||||
[m4_case(b4_percent_define_get([[parse.error]]), $@)])
|
||||
|
||||
# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE)
|
||||
# ------------------------------------------------------------------
|
||||
m4_define([b4_parse_error_bmatch],
|
||||
[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)])
|
||||
|
||||
|
||||
|
||||
# b4_union_if([IF-UNION-ARE-USED], [IF-NOT])
|
||||
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
||||
# ----------------------------------------------
|
||||
b4_percent_define_if_define([variant])
|
||||
# Depend on whether api.value.type is union, or variant.
|
||||
m4_define([b4_union_flag], [[0]])
|
||||
m4_define([b4_variant_flag], [[0]])
|
||||
b4_percent_define_ifdef([[api.value.type]],
|
||||
[m4_case(b4_percent_define_get_kind([[api.value.type]]), [keyword],
|
||||
[m4_case(b4_percent_define_get([[api.value.type]]), [variant],
|
||||
[m4_define([b4_variant_flag], [[1]])])])])
|
||||
[m4_case(b4_percent_define_get([[api.value.type]]),
|
||||
[union], [m4_define([b4_union_flag], [[1]])],
|
||||
[variant], [m4_define([b4_variant_flag], [[1]])])])])
|
||||
b4_define_flag_if([union])
|
||||
b4_define_flag_if([variant])
|
||||
|
||||
|
||||
|
@ -1071,10 +1193,10 @@ m4_define_default([b4_location_initial_line], [1])
|
|||
## Sanity checks. ##
|
||||
## --------------- ##
|
||||
|
||||
# api.location.prefix={...} (Java and C++).
|
||||
# api.location.type={...} (C, C++ and Java).
|
||||
b4_percent_define_check_kind([api.location.type], [code], [deprecated])
|
||||
|
||||
# api.position.prefix={...} (Java).
|
||||
# api.position.type={...} (Java).
|
||||
b4_percent_define_check_kind([api.position.type], [code], [deprecated])
|
||||
|
||||
# api.prefix >< %name-prefix.
|
||||
|
@ -1109,3 +1231,11 @@ b4_percent_define_ifdef([api.value.type],
|
|||
|
||||
# api.value.union.name.
|
||||
b4_percent_define_check_kind([api.value.union.name], [keyword])
|
||||
|
||||
# parse.error (custom|detailed) >< token-table.
|
||||
b4_token_table_if(
|
||||
[b4_parse_error_bmatch([custom\|detailed],
|
||||
[b4_complain_at(b4_percent_define_get_loc([parse.error]),
|
||||
[['%s' and '%s' cannot be used together]],
|
||||
[%token-table],
|
||||
[%define parse.error (custom|detailed)])])])
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# C++ skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
||||
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.cc]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
|
@ -0,0 +1,778 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Sanity checks, before defaults installed by c.m4.
|
||||
b4_percent_define_ifdef([[api.value.union.name]],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
||||
[named %union is invalid in C++])])
|
||||
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||
|
||||
m4_include(b4_skeletonsdir/[c.m4])
|
||||
|
||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||
b4_percent_define_check_kind([api.parser.class], [code], [deprecated])
|
||||
|
||||
|
||||
## ----- ##
|
||||
## C++. ##
|
||||
## ----- ##
|
||||
|
||||
# b4_comment(TEXT, [PREFIX])
|
||||
# --------------------------
|
||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||
m4_define([b4_comment],
|
||||
[_b4_comment([$1], [$2// ], [$2// ])])
|
||||
|
||||
|
||||
# b4_inline(hh|cc)
|
||||
# ----------------
|
||||
# Expand to `inline\n ` if $1 is hh.
|
||||
m4_define([b4_inline],
|
||||
[m4_case([$1],
|
||||
[cc], [],
|
||||
[hh], [[inline
|
||||
]],
|
||||
[m4_fatal([$0: invalid argument: $1])])])
|
||||
|
||||
|
||||
# b4_cxx_portability
|
||||
# ------------------
|
||||
m4_define([b4_cxx_portability],
|
||||
[#if defined __cplusplus
|
||||
# define YY_CPLUSPLUS __cplusplus
|
||||
#else
|
||||
# define YY_CPLUSPLUS 199711L
|
||||
#endif
|
||||
|
||||
// Support move semantics when possible.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
# define YY_MOVE std::move
|
||||
# define YY_MOVE_OR_COPY move
|
||||
# define YY_MOVE_REF(Type) Type&&
|
||||
# define YY_RVREF(Type) Type&&
|
||||
# define YY_COPY(Type) Type
|
||||
#else
|
||||
# define YY_MOVE
|
||||
# define YY_MOVE_OR_COPY copy
|
||||
# define YY_MOVE_REF(Type) Type&
|
||||
# define YY_RVREF(Type) const Type&
|
||||
# define YY_COPY(Type) const Type&
|
||||
#endif
|
||||
|
||||
// Support noexcept when possible.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
# define YY_NOEXCEPT noexcept
|
||||
# define YY_NOTHROW
|
||||
#else
|
||||
# define YY_NOEXCEPT
|
||||
# define YY_NOTHROW throw ()
|
||||
#endif
|
||||
|
||||
// Support constexpr when possible.
|
||||
#if 201703 <= YY_CPLUSPLUS
|
||||
# define YY_CONSTEXPR constexpr
|
||||
#else
|
||||
# define YY_CONSTEXPR
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [[parser]])
|
||||
|
||||
# Don't do that so that we remember whether we're using a user
|
||||
# request, or the default value.
|
||||
#
|
||||
# b4_percent_define_default([[api.location.type]], [[location]])
|
||||
|
||||
b4_percent_define_default([[api.filename.type]], [[const std::string]])
|
||||
# Make it a warning for those who used betas of Bison 3.0.
|
||||
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
|
||||
|
||||
b4_percent_define_default([[define_location_comparison]],
|
||||
[m4_if(b4_percent_define_get([[filename_type]]),
|
||||
[std::string], [[true]], [[false]])])
|
||||
|
||||
|
||||
|
||||
## ----------- ##
|
||||
## Namespace. ##
|
||||
## ----------- ##
|
||||
|
||||
m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
|
||||
|
||||
|
||||
# Don't permit an empty b4_namespace_ref. Any '::parser::foo' appended to it
|
||||
# would compile as an absolute reference with 'parser' in the global namespace.
|
||||
# b4_namespace_open would open an anonymous namespace and thus establish
|
||||
# internal linkage. This would compile. However, it's cryptic, and internal
|
||||
# linkage for the parser would be specified in all translation units that
|
||||
# include the header, which is always generated. If we ever need to permit
|
||||
# internal linkage somehow, surely we can find a cleaner approach.
|
||||
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||
[[namespace reference is empty]])])
|
||||
|
||||
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
||||
# invalid b4_namespace_ref that would be converted to a valid
|
||||
# b4_namespace_open. The problem is that Bison doesn't always output
|
||||
# b4_namespace_ref to uncommented code but should reserve the ability to do so
|
||||
# in future releases without risking breaking any existing user grammars.
|
||||
# Specifically, don't allow empty names as b4_namespace_open would just convert
|
||||
# those into anonymous namespaces, and that might tempt some users.
|
||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||
[[namespace reference has consecutive "::"]])])
|
||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||
[[namespace reference has a trailing "::"]])])
|
||||
|
||||
m4_define([b4_namespace_open],
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
||||
[^\(.\)[ ]*::], [\1])),
|
||||
[::], [ { namespace ])[ {]])])
|
||||
|
||||
m4_define([b4_namespace_close],
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
||||
[\1])),
|
||||
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the token kinds.
|
||||
m4_define([b4_token_enums],
|
||||
[[enum token_kind_type
|
||||
{
|
||||
]b4_symbol([-2], [id])[ = -2,
|
||||
]b4_symbol_foreach([b4_token_enum])dnl
|
||||
[ };]dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[enum symbol_kind_type
|
||||
{
|
||||
YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens.
|
||||
]b4_symbol(empty, kind_base)[ = -2,
|
||||
]b4_symbol_foreach([ b4_symbol_enum])dnl
|
||||
[ };]])
|
||||
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
|
||||
# b4_value_type_declare
|
||||
# ---------------------
|
||||
# Declare value_type.
|
||||
m4_define([b4_value_type_declare],
|
||||
[b4_value_type_setup[]dnl
|
||||
[ /// Symbol semantic values.
|
||||
]m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
||||
[code],
|
||||
[[ typedef ]b4_percent_define_get([[api.value.type]])[ value_type;]],
|
||||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||
[union\|union-directive],
|
||||
[[ union value_type
|
||||
{
|
||||
]b4_user_union_members[
|
||||
};]])])dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_public_types_declare
|
||||
# -----------------------
|
||||
# Define the public types: token, semantic value, location, and so forth.
|
||||
# Depending on %define token_lex, may be output in the header or source file.
|
||||
m4_define([b4_public_types_declare],
|
||||
[b4_glr2_cc_if(
|
||||
[b4_value_type_declare],
|
||||
[[#ifdef ]b4_api_PREFIX[STYPE
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type"
|
||||
# endif
|
||||
typedef ]b4_api_PREFIX[STYPE value_type;
|
||||
#else
|
||||
]b4_value_type_declare[
|
||||
#endif
|
||||
/// Backward compatibility (Bison 3.8).
|
||||
typedef value_type semantic_type;
|
||||
]])[]b4_locations_if([
|
||||
/// Symbol locations.
|
||||
typedef b4_percent_define_get([[api.location.type]],
|
||||
[[location]]) location_type;])[
|
||||
|
||||
/// Syntax errors thrown from user actions.
|
||||
struct syntax_error : std::runtime_error
|
||||
{
|
||||
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
||||
: std::runtime_error (m)]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}
|
||||
|
||||
syntax_error (const syntax_error& s)
|
||||
: std::runtime_error (s.what ())]b4_locations_if([
|
||||
, location (s.location)])[
|
||||
{}
|
||||
|
||||
~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([
|
||||
|
||||
location_type location;])[
|
||||
};
|
||||
|
||||
/// Token kinds.
|
||||
struct token
|
||||
{
|
||||
]b4_token_enums[]b4_glr2_cc_if([], [[
|
||||
/// Backward compatibility alias (Bison 3.6).
|
||||
typedef token_kind_type yytokentype;]])[
|
||||
};
|
||||
|
||||
/// Token kind, as returned by yylex.
|
||||
typedef token::token_kind_type token_kind_type;]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility alias (Bison 3.6).
|
||||
typedef token_kind_type token_type;]])[
|
||||
|
||||
/// Symbol kinds.
|
||||
struct symbol_kind
|
||||
{
|
||||
]b4_declare_symbol_enum[
|
||||
};
|
||||
|
||||
/// (Internal) symbol kind.
|
||||
typedef symbol_kind::symbol_kind_type symbol_kind_type;
|
||||
|
||||
/// The number of tokens.
|
||||
static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS;
|
||||
]])
|
||||
|
||||
|
||||
# b4_symbol_type_define
|
||||
# ---------------------
|
||||
# Define symbol_type, the external type for symbols used for symbol
|
||||
# constructors.
|
||||
m4_define([b4_symbol_type_define],
|
||||
[[ /// A complete symbol.
|
||||
///
|
||||
/// Expects its Base type to provide access to the symbol kind
|
||||
/// via kind ().
|
||||
///
|
||||
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
||||
template <typename Base>
|
||||
struct basic_symbol : Base
|
||||
{
|
||||
/// Alias to Base.
|
||||
typedef Base super_type;
|
||||
|
||||
/// Default constructor.
|
||||
basic_symbol () YY_NOEXCEPT
|
||||
: value ()]b4_locations_if([
|
||||
, location ()])[
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
basic_symbol (basic_symbol&& that)
|
||||
: Base (std::move (that))
|
||||
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||
, location (std::move (that.location))])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[std::move (that.value)])
|
||||
])[}
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
basic_symbol (const basic_symbol& that);]b4_variant_if([[
|
||||
|
||||
/// Constructors for typed symbols.
|
||||
]b4_type_foreach([b4_basic_symbol_constructor_define], [
|
||||
])], [[
|
||||
/// Constructor for valueless symbols.
|
||||
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
||||
YY_MOVE_REF (location_type) l])[);
|
||||
|
||||
/// Constructor for symbols with semantic value.
|
||||
basic_symbol (typename Base::kind_type t,
|
||||
YY_RVREF (value_type) v]b4_locations_if([,
|
||||
YY_RVREF (location_type) l])[);
|
||||
]])[
|
||||
/// Destroy the symbol.
|
||||
~basic_symbol ()
|
||||
{
|
||||
clear ();
|
||||
}
|
||||
|
||||
]b4_glr2_cc_if([[
|
||||
/// Copy assignment.
|
||||
basic_symbol& operator= (const basic_symbol& that)
|
||||
{
|
||||
Base::operator= (that);]b4_variant_if([[
|
||||
]b4_symbol_variant([this->kind ()], [value], [copy],
|
||||
[that.value])], [[
|
||||
value = that.value]])[;]b4_locations_if([[
|
||||
location = that.location;]])[
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Move assignment.
|
||||
basic_symbol& operator= (basic_symbol&& that)
|
||||
{
|
||||
Base::operator= (std::move (that));]b4_variant_if([[
|
||||
]b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[std::move (that.value)])], [[
|
||||
value = std::move (that.value)]])[;]b4_locations_if([[
|
||||
location = std::move (that.location);]])[
|
||||
return *this;
|
||||
}
|
||||
]])[
|
||||
|
||||
/// Destroy contents, and record that is empty.
|
||||
void clear () YY_NOEXCEPT
|
||||
{]b4_variant_if([[
|
||||
// User destructor.
|
||||
symbol_kind_type yykind = this->kind ();
|
||||
basic_symbol<Base>& yysym = *this;
|
||||
(void) yysym;
|
||||
switch (yykind)
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Value type destructor.
|
||||
]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[custom\|detailed],
|
||||
[[ /// The user-facing name of this symbol.
|
||||
const char *name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}]],
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
/// The user-facing name of this symbol.
|
||||
const char *name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /// The user-facing name of this symbol.
|
||||
std::string name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}]])[]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility (Bison 3.6).
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||
|
||||
/// Whether empty.
|
||||
bool empty () const YY_NOEXCEPT;
|
||||
|
||||
/// Destructive move, \a s is emptied into this.
|
||||
void move (basic_symbol& s);
|
||||
|
||||
/// The semantic value.
|
||||
value_type value;]b4_locations_if([
|
||||
|
||||
/// The location.
|
||||
location_type location;])[
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Assignment operator.
|
||||
basic_symbol& operator= (const basic_symbol& that);
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Type access provider for token (enum) based symbols.
|
||||
struct by_kind
|
||||
{
|
||||
/// The symbol kind as needed by the constructor.
|
||||
typedef token_kind_type kind_type;
|
||||
|
||||
/// Default constructor.
|
||||
by_kind () YY_NOEXCEPT;
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
by_kind (by_kind&& that) YY_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
by_kind (const by_kind& that) YY_NOEXCEPT;
|
||||
|
||||
/// Constructor from (external) token numbers.
|
||||
by_kind (kind_type t) YY_NOEXCEPT;
|
||||
|
||||
]b4_glr2_cc_if([[
|
||||
/// Copy assignment.
|
||||
by_kind& operator= (const by_kind& that);
|
||||
|
||||
/// Move assignment.
|
||||
by_kind& operator= (by_kind&& that);
|
||||
]])[
|
||||
|
||||
/// Record that this symbol is empty.
|
||||
void clear () YY_NOEXCEPT;
|
||||
|
||||
/// Steal the symbol kind from \a that.
|
||||
void move (by_kind& that);
|
||||
|
||||
/// The (internal) type number (corresponding to \a type).
|
||||
/// \a empty when empty.
|
||||
symbol_kind_type kind () const YY_NOEXCEPT;]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility (Bison 3.6).
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||
|
||||
/// The symbol kind.
|
||||
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
||||
symbol_kind_type kind_;
|
||||
};]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
||||
typedef by_kind by_type;]])[
|
||||
|
||||
/// "External" symbols: returned by the scanner.
|
||||
struct symbol_type : basic_symbol<by_kind>
|
||||
{]b4_variant_if([[
|
||||
/// Superclass.
|
||||
typedef basic_symbol<by_kind> super_type;
|
||||
|
||||
/// Empty symbol.
|
||||
symbol_type () YY_NOEXCEPT {}
|
||||
|
||||
/// Constructor for valueless symbols, and symbols from each type.
|
||||
]b4_type_foreach([_b4_symbol_constructor_define])dnl
|
||||
])[};
|
||||
]])
|
||||
|
||||
|
||||
# b4_public_types_define(hh|cc)
|
||||
# -----------------------------
|
||||
# Provide the implementation needed by the public types.
|
||||
m4_define([b4_public_types_define],
|
||||
[[ // basic_symbol.
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||
: Base (that)
|
||||
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
||||
, location (that.location)])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->kind ()], [value], [copy],
|
||||
[YY_MOVE (that.value)])
|
||||
])[}
|
||||
|
||||
]b4_variant_if([], [[
|
||||
/// Constructor for valueless symbols.
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
|
||||
: Base (t)
|
||||
, value ()]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
[YY_RVREF (value_type) v],
|
||||
b4_locations_if([YY_RVREF (location_type) l]))[)
|
||||
: Base (t)
|
||||
, value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([
|
||||
, location (YY_MOVE (l))])[
|
||||
{]b4_variant_if([[
|
||||
(void) v;
|
||||
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||
|
||||
]b4_glr2_cc_if([], [[
|
||||
template <typename Base>
|
||||
]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind ();
|
||||
}
|
||||
]])[
|
||||
|
||||
template <typename Base>
|
||||
bool
|
||||
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind () == ]b4_symbol(empty, kind)[;
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
void
|
||||
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
|
||||
{
|
||||
super_type::move (s);
|
||||
]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[YY_MOVE (s.value)])],
|
||||
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
||||
location = YY_MOVE (s.location);])[
|
||||
}
|
||||
|
||||
// by_kind.
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT
|
||||
: kind_ (]b4_symbol(empty, kind)[)
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
|
||||
: kind_ (that.kind_)
|
||||
{
|
||||
that.clear ();
|
||||
}
|
||||
#endif
|
||||
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
|
||||
: kind_ (that.kind_)
|
||||
{}
|
||||
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
|
||||
: kind_ (yytranslate_ (t))
|
||||
{}
|
||||
|
||||
]b4_glr2_cc_if([[
|
||||
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||
b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that)
|
||||
{
|
||||
kind_ = that.kind_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||
b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that)
|
||||
{
|
||||
kind_ = that.kind_;
|
||||
that.clear ();
|
||||
return *this;
|
||||
}
|
||||
]])[
|
||||
|
||||
]b4_inline([$1])[void
|
||||
]b4_parser_class[::by_kind::clear () YY_NOEXCEPT
|
||||
{
|
||||
kind_ = ]b4_symbol(empty, kind)[;
|
||||
}
|
||||
|
||||
]b4_inline([$1])[void
|
||||
]b4_parser_class[::by_kind::move (by_kind& that)
|
||||
{
|
||||
kind_ = that.kind_;
|
||||
that.clear ();
|
||||
}
|
||||
|
||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT
|
||||
{
|
||||
return kind_;
|
||||
}
|
||||
|
||||
]b4_glr2_cc_if([], [[
|
||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind ();
|
||||
}
|
||||
]])[
|
||||
]])
|
||||
|
||||
|
||||
# b4_token_constructor_define
|
||||
# ----------------------------
|
||||
# Define make_FOO for all the token kinds.
|
||||
# Use at class-level. Redefined in variant.hh.
|
||||
m4_define([b4_token_constructor_define], [])
|
||||
|
||||
|
||||
# b4_yytranslate_define(cc|hh)
|
||||
# ----------------------------
|
||||
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
||||
# sometimes in the cc file.
|
||||
m4_define([b4_yytranslate_define],
|
||||
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT
|
||||
{
|
||||
]b4_api_token_raw_if(
|
||||
[[ return static_cast<symbol_kind_type> (t);]],
|
||||
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||
// TOKEN-NUM as returned by yylex.
|
||||
static
|
||||
const ]b4_int_type_for([b4_translate])[
|
||||
translate_table[] =
|
||||
{
|
||||
]b4_translate[
|
||||
};
|
||||
// Last valid token kind.
|
||||
const int code_max = ]b4_code_max[;
|
||||
|
||||
if (t <= 0)
|
||||
return symbol_kind::]b4_symbol_prefix[YYEOF;
|
||||
else if (t <= code_max)
|
||||
return static_cast <symbol_kind_type> (translate_table[t]);
|
||||
else
|
||||
return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
# b4_lhs_value([TYPE])
|
||||
# --------------------
|
||||
m4_define([b4_lhs_value],
|
||||
[b4_symbol_value([yyval], [$1])])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, POS, [TYPE])
|
||||
# --------------------------------------
|
||||
# FIXME: Dead code.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
||||
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[(yylocation_stack_@{($1) - ($2)@})])
|
||||
|
||||
|
||||
# b4_parse_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
# Change the parameter names from "foo" into "foo_yyarg", so that
|
||||
# there is no collision bw the user chosen attribute name, and the
|
||||
# argument name in the constructor.
|
||||
m4_define([b4_parse_param_decl],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
|
||||
|
||||
m4_define([b4_parse_param_decl_1],
|
||||
[$1_yyarg])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_cons
|
||||
# -------------------
|
||||
# Extra initialisations of the constructor.
|
||||
m4_define([b4_parse_param_cons],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
b4_cc_constructor_calls(b4_parse_param)])])
|
||||
m4_define([b4_cc_constructor_calls],
|
||||
[m4_map_sep([b4_cc_constructor_call], [,
|
||||
], [$@])])
|
||||
m4_define([b4_cc_constructor_call],
|
||||
[$2 ($2_yyarg)])
|
||||
|
||||
# b4_parse_param_vars
|
||||
# -------------------
|
||||
# Extra instance variables.
|
||||
m4_define([b4_parse_param_vars],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
// User arguments.
|
||||
b4_cc_var_decls(b4_parse_param)])])
|
||||
m4_define([b4_cc_var_decls],
|
||||
[m4_map_sep([b4_cc_var_decl], [
|
||||
], [$@])])
|
||||
m4_define([b4_cc_var_decl],
|
||||
[ $1;])
|
||||
|
||||
|
||||
## ---------##
|
||||
## Values. ##
|
||||
## ---------##
|
||||
|
||||
# b4_yylloc_default_define
|
||||
# ------------------------
|
||||
# Define YYLLOC_DEFAULT.
|
||||
m4_define([b4_yylloc_default_define],
|
||||
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
If N is 0, then set CURRENT to the empty location which ends
|
||||
the previous symbol: RHS[0] (always defined). */
|
||||
|
||||
# ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do \
|
||||
if (N) \
|
||||
{ \
|
||||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
||||
(Current).end = YYRHSLOC (Rhs, N).end; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||
} \
|
||||
while (false)
|
||||
# endif
|
||||
]])
|
||||
|
||||
## -------- ##
|
||||
## Checks. ##
|
||||
## -------- ##
|
||||
|
||||
b4_token_ctor_if([b4_variant_if([],
|
||||
[b4_fatal_at(b4_percent_define_get_loc(api.token.constructor),
|
||||
[cannot use '%s' without '%s'],
|
||||
[%define api.token.constructor],
|
||||
[%define api.value.type variant]))])])
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Common code for C-like languages (C, C++, Java, etc.)
|
||||
|
||||
# Copyright (C) 2012-2015, 2018-2019 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2015, 2018-2021 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
|
||||
|
@ -15,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, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
||||
# --------------------------------------
|
||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||
# Avoid adding indentation to the first line, as the indentation comes
|
||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||
# Turn "*/" in TEXT into "* /" so that we don't unexpectedly close
|
||||
# the comments before its end.
|
||||
#
|
||||
# Prefix all the output lines with PREFIX.
|
||||
m4_define([_b4_comment],
|
||||
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
|
||||
[$2[]b4_gsub(m4_expand([$1]),
|
||||
[[*]/], [*\\/],
|
||||
[/[*]], [/\\*],
|
||||
[
|
||||
\(.\)], [
|
||||
$3\1])$4])
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# C skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
||||
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[yacc.c]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# C M4 Macros for Bison.
|
||||
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation,
|
||||
# Copyright (C) 2002, 2004-2015, 2018-2021 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
@ -16,7 +16,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, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
m4_include(b4_skeletonsdir/[c-like.m4])
|
||||
|
||||
|
@ -58,11 +58,11 @@ m4_define([b4_cpp_guard_close],
|
|||
# b4_pull_flag if they use the values of the %define variables api.pure or
|
||||
# api.push-pull.
|
||||
m4_define([b4_identification],
|
||||
[[/* Identify Bison output. */
|
||||
#define YYBISON 1
|
||||
[[/* Identify Bison output, and Bison version. */
|
||||
#define YYBISON ]b4_version[
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "]b4_version["
|
||||
/* Bison version string. */
|
||||
#define YYBISON_VERSION "]b4_version_string["
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[
|
||||
|
@ -101,32 +101,45 @@ m4_define_default([b4_prefix], [b4_api_prefix])
|
|||
b4_percent_define_default([[api.value.union.name]],
|
||||
[b4_api_PREFIX[][STYPE]])
|
||||
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]])
|
||||
|
||||
## ------------------------ ##
|
||||
## Pure/impure interfaces. ##
|
||||
## ------------------------ ##
|
||||
|
||||
# b4_lex_formals
|
||||
# --------------
|
||||
# b4_yylex_formals
|
||||
# ----------------
|
||||
# All the yylex formal arguments.
|
||||
# b4_lex_param arrives quoted twice, but we want to keep only one level.
|
||||
m4_define([b4_lex_formals],
|
||||
[b4_pure_if([[[[YYSTYPE *yylvalp]], [[&yylval]]][]dnl
|
||||
b4_locations_if([, [[YYLTYPE *yyllocp], [&yylloc]]])])dnl
|
||||
m4_define([b4_yylex_formals],
|
||||
[b4_pure_if([[[b4_api_PREFIX[STYPE *yylvalp]], [[&yylval]]][]dnl
|
||||
b4_locations_if([, [b4_api_PREFIX[LTYPE *yyllocp], [&yylloc]]])])dnl
|
||||
m4_ifdef([b4_lex_param], [, ]b4_lex_param)])
|
||||
|
||||
|
||||
# b4_lex
|
||||
# ------
|
||||
# b4_yylex
|
||||
# --------
|
||||
# Call yylex.
|
||||
m4_define([b4_lex],
|
||||
[b4_function_call([yylex], [int], b4_lex_formals)])
|
||||
m4_define([b4_yylex],
|
||||
[b4_function_call([yylex], [int], b4_yylex_formals)])
|
||||
|
||||
|
||||
# b4_user_args
|
||||
# ------------
|
||||
m4_define([b4_user_args],
|
||||
[m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])])
|
||||
[m4_ifset([b4_parse_param], [, b4_user_args_no_comma])])
|
||||
|
||||
# b4_user_args_no_comma
|
||||
# ---------------------
|
||||
m4_define([b4_user_args_no_comma],
|
||||
[m4_ifset([b4_parse_param], [b4_args(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_user_formals
|
||||
# ---------------
|
||||
# The possible parse-params formal arguments preceded by a comma.
|
||||
m4_define([b4_user_formals],
|
||||
[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_parse_param
|
||||
|
@ -150,13 +163,20 @@ m4_popdef([$2])dnl
|
|||
m4_popdef([$1])dnl
|
||||
])])
|
||||
|
||||
|
||||
# b4_use(EXPR)
|
||||
# ------------
|
||||
# Pacify the compiler about some maybe unused value.
|
||||
m4_define([b4_use],
|
||||
[YY_USE ($1)])
|
||||
|
||||
# b4_parse_param_use([VAL], [LOC])
|
||||
# --------------------------------
|
||||
# 'YYUSE' VAL, LOC if locations are enabled, and all the parse-params.
|
||||
# 'YY_USE' VAL, LOC if locations are enabled, and all the parse-params.
|
||||
m4_define([b4_parse_param_use],
|
||||
[m4_ifvaln([$1], [ YYUSE ([$1]);])dnl
|
||||
b4_locations_if([m4_ifvaln([$2], [ YYUSE ([$2]);])])dnl
|
||||
b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
||||
[m4_ifvaln([$1], [ b4_use([$1]);])dnl
|
||||
b4_locations_if([m4_ifvaln([$2], [ b4_use([$2]);])])dnl
|
||||
b4_parse_param_for([Decl], [Formal], [ b4_use(Formal);
|
||||
])dnl
|
||||
])
|
||||
|
||||
|
@ -167,38 +187,170 @@ b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
|||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
# Return a narrow int type able to handle integers ranging from MIN
|
||||
# to MAX (included) in portable C code. Assume MIN and MAX fall in
|
||||
# 'int' range.
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||
b4_ints_in($@, [-128], [127]), [1], [signed char],
|
||||
[m4_if(b4_ints_in($@, [-127], [127]), [1], [signed char],
|
||||
b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||
|
||||
b4_ints_in($@, [-32767], [32767]), [1], [short],
|
||||
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
|
||||
m4_eval([0 <= $1]), [1], [unsigned],
|
||||
|
||||
[int])])
|
||||
|
||||
# b4_c99_int_type(MIN, MAX)
|
||||
# -------------------------
|
||||
# Like b4_int_type, but for C99.
|
||||
# b4_c99_int_type_define replaces b4_int_type with this.
|
||||
m4_define([b4_c99_int_type],
|
||||
[m4_if(b4_ints_in($@, [-127], [127]), [1], [yytype_int8],
|
||||
b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
|
||||
|
||||
b4_ints_in($@, [-32767], [32767]), [1], [yytype_int16],
|
||||
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
|
||||
|
||||
[int])])
|
||||
|
||||
# b4_c99_int_type_define
|
||||
# ----------------------
|
||||
# Define private types suitable for holding small integers in C99 or later.
|
||||
m4_define([b4_c99_int_type_define],
|
||||
[m4_copy_force([b4_c99_int_type], [b4_int_type])dnl
|
||||
[#ifdef short
|
||||
# undef short
|
||||
#endif
|
||||
|
||||
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
|
||||
<limits.h> and (if available) <stdint.h> are included
|
||||
so that the code can choose integer types of a good width. */
|
||||
|
||||
#ifndef __PTRDIFF_MAX__
|
||||
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||
# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_STDINT_H
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Narrow types that promote to a signed type and that can represent a
|
||||
signed or unsigned integer of at least N bits. In tables they can
|
||||
save space and decrease cache pressure. Promoting to a signed type
|
||||
helps avoid bugs in integer arithmetic. */
|
||||
|
||||
#ifdef __INT_LEAST8_MAX__
|
||||
typedef __INT_LEAST8_TYPE__ yytype_int8;
|
||||
#elif defined YY_STDINT_H
|
||||
typedef int_least8_t yytype_int8;
|
||||
#else
|
||||
typedef signed char yytype_int8;
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST16_MAX__
|
||||
typedef __INT_LEAST16_TYPE__ yytype_int16;
|
||||
#elif defined YY_STDINT_H
|
||||
typedef int_least16_t yytype_int16;
|
||||
#else
|
||||
typedef short yytype_int16;
|
||||
#endif
|
||||
|
||||
/* Work around bug in HP-UX 11.23, which defines these macros
|
||||
incorrectly for preprocessor constants. This workaround can likely
|
||||
be removed in 2023, as HPE has promised support for HP-UX 11.23
|
||||
(aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
|
||||
<https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
|
||||
#ifdef __hpux
|
||||
# undef UINT_LEAST8_MAX
|
||||
# undef UINT_LEAST16_MAX
|
||||
# define UINT_LEAST8_MAX 255
|
||||
# define UINT_LEAST16_MAX 65535
|
||||
#endif
|
||||
|
||||
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
|
||||
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
|
||||
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
|
||||
&& UINT_LEAST8_MAX <= INT_MAX)
|
||||
typedef uint_least8_t yytype_uint8;
|
||||
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
|
||||
typedef unsigned char yytype_uint8;
|
||||
#else
|
||||
typedef short yytype_uint8;
|
||||
#endif
|
||||
|
||||
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
|
||||
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
|
||||
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
|
||||
&& UINT_LEAST16_MAX <= INT_MAX)
|
||||
typedef uint_least16_t yytype_uint16;
|
||||
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
|
||||
typedef unsigned short yytype_uint16;
|
||||
#else
|
||||
typedef int yytype_uint16;
|
||||
#endif]])
|
||||
|
||||
|
||||
# b4_sizes_types_define
|
||||
# ---------------------
|
||||
# Define YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM,
|
||||
# and YYSIZEOF.
|
||||
m4_define([b4_sizes_types_define],
|
||||
[[#ifndef YYPTRDIFF_T
|
||||
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
|
||||
# define YYPTRDIFF_T __PTRDIFF_TYPE__
|
||||
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
|
||||
# elif defined PTRDIFF_MAX
|
||||
# ifndef ptrdiff_t
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# define YYPTRDIFF_T ptrdiff_t
|
||||
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
|
||||
# else
|
||||
# define YYPTRDIFF_T long
|
||||
# define YYPTRDIFF_MAXIMUM LONG_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
# ifdef __SIZE_TYPE__
|
||||
# define YYSIZE_T __SIZE_TYPE__
|
||||
# elif defined size_t
|
||||
# define YYSIZE_T size_t
|
||||
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYSIZE_MAXIMUM \
|
||||
YY_CAST (YYPTRDIFF_T, \
|
||||
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
|
||||
? YYPTRDIFF_MAXIMUM \
|
||||
: YY_CAST (YYSIZE_T, -1)))
|
||||
|
||||
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
|
||||
]])
|
||||
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# Return a narrow int type able to handle numbers ranging from
|
||||
# 'NAME_min' to 'NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
|
||||
# b4_table_value_equals(TABLE, VALUE, LITERAL)
|
||||
# --------------------------------------------
|
||||
# b4_table_value_equals(TABLE, VALUE, LITERAL, SYMBOL)
|
||||
# ----------------------------------------------------
|
||||
# Without inducing a comparison warning from the compiler, check if the
|
||||
# literal value LITERAL equals VALUE from table TABLE, which must have
|
||||
# TABLE_min and TABLE_max defined.
|
||||
# TABLE_min and TABLE_max defined. SYMBOL denotes
|
||||
m4_define([b4_table_value_equals],
|
||||
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
||||
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
||||
[[0]],
|
||||
[(!!(($2) == ($3)))])])
|
||||
[(($2) == $4)])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
|
@ -210,54 +362,72 @@ m4_define([b4_table_value_equals],
|
|||
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
||||
# _Noreturn.
|
||||
m4_define([b4_attribute_define],
|
||||
[[#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)
|
||||
[[#ifndef YY_ATTRIBUTE_PURE
|
||||
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
||||
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
# else
|
||||
# define YY_ATTRIBUTE(Spec) /* empty */
|
||||
# define YY_ATTRIBUTE_PURE
|
||||
# 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__))
|
||||
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
|
||||
# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define YY_ATTRIBUTE_UNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
||||
#if ! defined _Noreturn
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
]dnl This is close to lib/_Noreturn.h, except that we do enable
|
||||
dnl the use of [[noreturn]], because _Noreturn is used in places
|
||||
dnl where [[noreturn]] works in C++. We need this in particular
|
||||
dnl because of glr.cc which compiles code from glr.c in C++.
|
||||
dnl And the C++ compiler chokes on _Noreturn. Also, we do not
|
||||
dnl use C' _Noreturn in C++, to avoid -Wc11-extensions warnings.
|
||||
[#ifndef _Noreturn
|
||||
# if (defined __cplusplus \
|
||||
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
||||
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
|
||||
# define _Noreturn [[noreturn]]
|
||||
# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)
|
||||
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|
||||
|| 0x5110 <= __SUNPRO_C)
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# elif defined _MSC_VER && 1200 <= _MSC_VER
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
# elif ((!defined __cplusplus || defined __clang__) \
|
||||
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
||||
|| (!defined __STRICT_ANSI__ \
|
||||
&& (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|
||||
|| (defined __apple_build_version__ \
|
||||
? 6000000 <= __apple_build_version__ \
|
||||
: 3 < __clang_major__ + (5 <= __clang_minor__))))))
|
||||
/* _Noreturn works as-is. */
|
||||
# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
|
||||
|| 0x5110 <= __SUNPRO_C)
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
#endif
|
||||
|
||||
]])[/* Suppress unused-variable warnings by "using" E. */
|
||||
#if ! defined lint || defined __GNUC__
|
||||
# define YYUSE(E) ((void) (E))
|
||||
# define YY_USE(E) ((void) (E))
|
||||
#else
|
||||
# define YYUSE(E) /* empty */
|
||||
# define YY_USE(E) /* empty */
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && ! defined __ICC && 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\"")\
|
||||
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
|
||||
# else
|
||||
# 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 \
|
||||
# endif
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#else
|
||||
# define YY_INITIAL_VALUE(Value) Value
|
||||
|
@ -269,9 +439,36 @@ m4_define([b4_attribute_define],
|
|||
#ifndef YY_INITIAL_VALUE
|
||||
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
|
||||
# define YY_IGNORE_USELESS_CAST_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
|
||||
# define YY_IGNORE_USELESS_CAST_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#endif
|
||||
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
|
||||
# define YY_IGNORE_USELESS_CAST_BEGIN
|
||||
# define YY_IGNORE_USELESS_CAST_END
|
||||
#endif
|
||||
]])
|
||||
|
||||
|
||||
# b4_cast_define
|
||||
# --------------
|
||||
m4_define([b4_cast_define],
|
||||
[# ifndef YY_CAST
|
||||
# ifdef __cplusplus
|
||||
# define YY_CAST(Type, Val) static_cast<Type> (Val)
|
||||
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
|
||||
# else
|
||||
# define YY_CAST(Type, Val) ((Type) (Val))
|
||||
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
|
||||
# endif
|
||||
# endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_null_define
|
||||
# --------------
|
||||
# Portability issues: define a YY_NULLPTR appropriate for the current
|
||||
|
@ -309,7 +506,7 @@ m4_define([b4_null], [YY_NULLPTR])
|
|||
# -------------------------------------------------------------
|
||||
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
||||
m4_define([b4_integral_parser_table_define],
|
||||
[m4_ifvaln([$3], [b4_comment([$3], [ ])])dnl
|
||||
[m4_ifvaln([$3], [b4_comment([$3])])dnl
|
||||
static const b4_int_type_for([$2]) yy$1[[]] =
|
||||
{
|
||||
$2
|
||||
|
@ -317,9 +514,22 @@ static const b4_int_type_for([$2]) yy$1[[]] =
|
|||
])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
# Because C enums are not scoped, because tokens are exposed in the
|
||||
# header, and because these tokens are common to all the parsers, we
|
||||
# need to make sure their names don't collide: use the api.prefix.
|
||||
# YYEOF is special, since the user may give it a different name.
|
||||
m4_define([b4_symbol(-2, id)], [b4_api_PREFIX[][EMPTY]])
|
||||
m4_define([b4_symbol(-2, tag)], [[No symbol.]])
|
||||
|
||||
m4_if(b4_symbol(eof, id), [YYEOF],
|
||||
[m4_define([b4_symbol(0, id)], [b4_api_PREFIX[][EOF]])])
|
||||
m4_define([b4_symbol(1, id)], [b4_api_PREFIX[][error]])
|
||||
m4_define([b4_symbol(2, id)], [b4_api_PREFIX[][UNDEF]])
|
||||
|
||||
|
||||
# b4_token_define(TOKEN-NUM)
|
||||
# --------------------------
|
||||
|
@ -331,44 +541,92 @@ m4_define([b4_token_define],
|
|||
# ----------------
|
||||
# Output the definition of the tokens.
|
||||
m4_define([b4_token_defines],
|
||||
[b4_any_token_visible_if([/* Tokens. */
|
||||
m4_join([
|
||||
[[/* Token kinds. */
|
||||
#define ]b4_symbol(empty, [id])[ -2
|
||||
]m4_join([
|
||||
], b4_symbol_map([b4_token_define]))
|
||||
])])
|
||||
])
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NUM)
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_format([%s = %s], [$1])])
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s = %s%s%s]],
|
||||
b4_symbol([$1], [id]),
|
||||
b4_symbol([$1], b4_api_token_raw_if([[number]], [[code]])),
|
||||
m4_if([$1], b4_last_enum_token, [], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])])
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
# The definition of the token kinds.
|
||||
m4_define([b4_token_enums],
|
||||
[b4_any_token_visible_if([[/* Token type. */
|
||||
[b4_any_token_visible_if([[/* Token kinds. */
|
||||
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
||||
# define ]b4_api_PREFIX[TOKENTYPE
|
||||
enum ]b4_api_prefix[tokentype
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
b4_symbol_map([b4_token_enum]))[
|
||||
};
|
||||
]b4_symbol(empty, [id])[ = -2,
|
||||
]b4_symbol_foreach([b4_token_enum])dnl
|
||||
[ };
|
||||
typedef enum ]b4_api_prefix[tokentype ]b4_api_prefix[token_kind_t;
|
||||
#endif
|
||||
]])])
|
||||
|
||||
|
||||
# b4_token_enums_defines
|
||||
# ----------------------
|
||||
# Output the definition of the tokens (if there are any) as enums and,
|
||||
# The definition of the tokens (if there are any) as enums and,
|
||||
# if POSIX Yacc is enabled, as #defines.
|
||||
m4_define([b4_token_enums_defines],
|
||||
[b4_token_enums[]b4_yacc_if([b4_token_defines])])
|
||||
|
||||
|
||||
# b4_symbol_translate(STRING)
|
||||
# ---------------------------
|
||||
# Used by "bison" in the array of symbol names to mark those that
|
||||
# require translation.
|
||||
m4_define([b4_symbol_translate],
|
||||
[[N_($1)]])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-40s %s],
|
||||
m4_format([[%s = %s%s%s]],
|
||||
b4_symbol([$1], [kind_base]),
|
||||
[$1],
|
||||
m4_if([$1], b4_last_symbol, [], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[/* Symbol kind. */
|
||||
enum yysymbol_kind_t
|
||||
{
|
||||
]b4_symbol(empty, [kind_base])[ = -2,
|
||||
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||
[};
|
||||
typedef enum yysymbol_kind_t yysymbol_kind_t;
|
||||
]])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
@ -392,15 +650,6 @@ m4_define([b4_symbol_value],
|
|||
## ---------------------- ##
|
||||
|
||||
|
||||
# b4_function_define(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# -----------------------------------------------------------
|
||||
# Declare the function NAME in C.
|
||||
m4_define([b4_function_define],
|
||||
[$2
|
||||
$1 (b4_formals(m4_shift2($@)))[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_formals([DECL1, NAME1], ...)
|
||||
# -------------------------------
|
||||
# The formal arguments of a C function definition.
|
||||
|
@ -413,12 +662,6 @@ m4_define([b4_formal],
|
|||
[$1])
|
||||
|
||||
|
||||
|
||||
## ----------------------- ##
|
||||
## Declaring C functions. ##
|
||||
## ----------------------- ##
|
||||
|
||||
|
||||
# b4_function_declare(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ------------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
|
@ -428,7 +671,6 @@ m4_define([b4_function_declare],
|
|||
|
||||
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Calling C functions. ##
|
||||
## --------------------- ##
|
||||
|
@ -465,12 +707,12 @@ m4_define([b4_sync_start], [[#]line $1 $2])
|
|||
## User actions. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_case(LABEL, STATEMENTS)
|
||||
# --------------------------
|
||||
# b4_case(LABEL, STATEMENTS, [COMMENTS])
|
||||
# --------------------------------------
|
||||
m4_define([b4_case],
|
||||
[ case $1:
|
||||
[ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
||||
$2
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;])
|
||||
|
||||
|
||||
|
@ -480,7 +722,7 @@ m4_define([b4_predicate_case],
|
|||
[ case $1:
|
||||
if (! (
|
||||
$2)) YYERROR;
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;])
|
||||
|
||||
|
||||
|
@ -492,18 +734,15 @@ m4_define_default([b4_yydestruct_define],
|
|||
| Release the memory associated to this symbol. |
|
||||
`-----------------------------------------------*/
|
||||
|
||||
]b4_function_define([yydestruct],
|
||||
[static void],
|
||||
[[const char *yymsg], [yymsg]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE *yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yydestruct (const char *yymsg,
|
||||
yysymbol_kind_t yykind, YYSTYPE *yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
||||
[ if (!yymsg)
|
||||
yymsg = "Deleting";
|
||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
|
||||
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
]b4_symbol_actions([destructor])[
|
||||
|
@ -521,48 +760,39 @@ m4_define_default([b4_yy_symbol_print_define],
|
|||
| Print this symbol's value on YYO. |
|
||||
`-----------------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_value_print],
|
||||
[static void],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yy_symbol_value_print (FILE *yyo,
|
||||
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
FILE *yyoutput = yyo;
|
||||
]b4_parse_param_use([yyoutput], [yylocationp])dnl
|
||||
[ if (!yyvaluep)
|
||||
return;]
|
||||
dnl glr.c does not feature yytoknum.
|
||||
m4_if(b4_skeleton, ["yacc.c"],
|
||||
[[# ifdef YYPRINT
|
||||
if (yytype < YYNTOKENS)
|
||||
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
|
||||
# endif
|
||||
]])dnl
|
||||
b4_symbol_actions([printer])[
|
||||
}
|
||||
b4_percent_code_get([[pre-printer]])dnl
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
b4_symbol_actions([printer])
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
b4_percent_code_get([[post-printer]])dnl
|
||||
[}
|
||||
|
||||
|
||||
/*---------------------------.
|
||||
| Print this symbol on YYO. |
|
||||
`---------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yy_symbol_print (FILE *yyo,
|
||||
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
YYFPRINTF (yyo, "%s %s (",
|
||||
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
|
||||
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
|
||||
|
||||
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
|
||||
]b4_locations_if([ YYLOCATION_PRINT (yyo, yylocationp);
|
||||
YYFPRINTF (yyo, ": ");
|
||||
])dnl
|
||||
[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl
|
||||
[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
|
||||
b4_locations_if([, yylocationp])[]b4_user_args[);
|
||||
YYFPRINTF (yyo, ")");
|
||||
}]dnl
|
||||
|
@ -588,11 +818,11 @@ m4_define([b4_symbol_type_register],
|
|||
[m4_define([b4_symbol($1, type_tag)],
|
||||
[b4_symbol_if([$1], [has_id],
|
||||
[b4_symbol([$1], [id])],
|
||||
[yytype_[]b4_symbol([$1], [number])])])dnl
|
||||
[yykind_[]b4_symbol([$1], [number])])])dnl
|
||||
m4_append([b4_union_members],
|
||||
m4_expand([
|
||||
b4_symbol_tag_comment([$1])dnl
|
||||
b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]))
|
||||
m4_expand([m4_format([ %-40s %s],
|
||||
m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]),
|
||||
[b4_symbol_tag_comment([$1])])]))
|
||||
])
|
||||
|
||||
|
||||
|
@ -709,13 +939,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
|
|||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||
[union\|union-directive],
|
||||
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
||||
union ]b4_percent_define_get([[api.value.union.name]])[
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||
[union ]b4_percent_define_get([[api.value.union.name]])[
|
||||
{
|
||||
]b4_user_union_members[
|
||||
};
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
||||
typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
||||
[typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
||||
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
|
||||
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
@ -726,7 +956,10 @@ typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[S
|
|||
# -----------------------
|
||||
m4_define([b4_location_type_define],
|
||||
[[/* Location type. */
|
||||
#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
||||
]b4_percent_define_ifdef([[api.location.type]],
|
||||
[[typedef ]b4_percent_define_get([[api.location.type]])[ ]b4_api_PREFIX[LTYPE;
|
||||
]],
|
||||
[[#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
||||
typedef struct ]b4_api_PREFIX[LTYPE ]b4_api_PREFIX[LTYPE;
|
||||
struct ]b4_api_PREFIX[LTYPE
|
||||
{
|
||||
|
@ -738,12 +971,12 @@ struct ]b4_api_PREFIX[LTYPE
|
|||
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
||||
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
]])
|
||||
]])])
|
||||
|
||||
|
||||
# b4_declare_yylstype
|
||||
# -------------------
|
||||
# Declarations that might either go into the header (if --defines) or
|
||||
# Declarations that might either go into the header (if --header) or
|
||||
# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
|
||||
m4_define([b4_declare_yylstype],
|
||||
[b4_value_type_define[]b4_locations_if([
|
||||
|
@ -813,25 +1046,30 @@ m4_define([b4_yylloc_default_define],
|
|||
#endif
|
||||
]])
|
||||
|
||||
# b4_yy_location_print_define
|
||||
# ---------------------------
|
||||
# Define YY_LOCATION_PRINT.
|
||||
m4_define([b4_yy_location_print_define],
|
||||
# b4_yylocation_print_define
|
||||
# --------------------------
|
||||
# Define YYLOCATION_PRINT.
|
||||
m4_define([b4_yylocation_print_define],
|
||||
[b4_locations_if([[
|
||||
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
||||
/* YYLOCATION_PRINT -- Print the location on the stream.
|
||||
This macro was not mandated originally: define only if we know
|
||||
we won't break user code: when these are the locations we know. */
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||
# ifndef YYLOCATION_PRINT
|
||||
|
||||
# if defined YY_LOCATION_PRINT
|
||||
|
||||
/* Temporary convenience wrapper in case some people defined the
|
||||
undocumented and private YY_LOCATION_PRINT macros. */
|
||||
# define YYLOCATION_PRINT(File, Loc) YY_LOCATION_PRINT(File, *(Loc))
|
||||
|
||||
# elif defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||
|
||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||
|
||||
YY_ATTRIBUTE_UNUSED
|
||||
]b4_function_define([yy_location_print_],
|
||||
[static int],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[YYLTYPE const * const yylocp], [yylocp]])[
|
||||
static int
|
||||
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
||||
{
|
||||
int res = 0;
|
||||
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
||||
|
@ -853,19 +1091,23 @@ YY_ATTRIBUTE_UNUSED
|
|||
res += YYFPRINTF (yyo, "-%d", end_col);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
yy_location_print_ (File, &(Loc))
|
||||
# define YYLOCATION_PRINT yy_location_print_
|
||||
|
||||
# else
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif
|
||||
#endif]],
|
||||
[[/* This macro is provided for backward compatibility. */
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
#endif]])
|
||||
/* Temporary convenience wrapper in case some people defined the
|
||||
undocumented and private YY_LOCATION_PRINT macros. */
|
||||
# define YY_LOCATION_PRINT(File, Loc) YYLOCATION_PRINT(File, &(Loc))
|
||||
|
||||
# else
|
||||
|
||||
# define YYLOCATION_PRINT(File, Loc) ((void) 0)
|
||||
/* Temporary convenience wrapper in case some people defined the
|
||||
undocumented and private YY_LOCATION_PRINT macros. */
|
||||
# define YY_LOCATION_PRINT YYLOCATION_PRINT
|
||||
|
||||
# endif
|
||||
# endif /* !defined YYLOCATION_PRINT */]])
|
||||
])
|
||||
|
||||
# b4_yyloc_default
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# D skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [b4_complain([%%glr-parser not supported for D])])
|
||||
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for D])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.d]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
|
@ -0,0 +1,628 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# D language support for Bison
|
||||
|
||||
# Copyright (C) 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
m4_include(b4_skeletonsdir/[c-like.m4])
|
||||
|
||||
|
||||
# b4_symbol_action(SYMBOL-NUM, ACTION)
|
||||
# ------------------------------------
|
||||
# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
|
||||
m4_define([b4_symbol_action],
|
||||
[b4_symbol_if([$1], [has_$2],
|
||||
[b4_dollar_pushdef([yyval],
|
||||
[$1],
|
||||
[],
|
||||
[yyloc])dnl
|
||||
_b4_symbol_case([$1])[]dnl
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;
|
||||
|
||||
b4_dollar_popdef[]dnl
|
||||
])])
|
||||
|
||||
|
||||
# b4_use(EXPR)
|
||||
# ------------
|
||||
# Pacify the compiler about some maybe unused value.
|
||||
m4_define([b4_use],
|
||||
[])
|
||||
|
||||
|
||||
# b4_sync_start(LINE, FILE)
|
||||
# -------------------------
|
||||
m4_define([b4_sync_start], [[#]line $1 $2])
|
||||
|
||||
|
||||
# b4_list2(LIST1, LIST2)
|
||||
# ----------------------
|
||||
# Join two lists with a comma if necessary.
|
||||
m4_define([b4_list2],
|
||||
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
||||
|
||||
|
||||
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
||||
# -------------------------------------------
|
||||
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
||||
# otherwise NOT.
|
||||
m4_define([b4_percent_define_get3],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
||||
|
||||
# b4_percent_define_if_get2(ARG1, ARG2, DEF, NOT)
|
||||
# -----------------------------------------------
|
||||
# Expand to the value of DEF if ARG1 or ARG2 are %define'ed,
|
||||
# otherwise NOT.
|
||||
m4_define([b4_percent_define_if_get2],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[$3], [m4_ifval(m4_quote(b4_percent_define_get([$2])),
|
||||
[$3], [$4])])])
|
||||
|
||||
# b4_percent_define_class_before_interface(CLASS, INTERFACE)
|
||||
# ----------------------------------------------------------
|
||||
# Expand to a ', ' if both a class and an interface have been %define'ed
|
||||
m4_define([b4_percent_define_class_before_interface],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$2])),
|
||||
[, ])])])
|
||||
|
||||
|
||||
# b4_flag_value(BOOLEAN-FLAG)
|
||||
# ---------------------------
|
||||
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||
|
||||
|
||||
# b4_parser_class_declaration
|
||||
# ---------------------------
|
||||
# The declaration of the parser class ("class YYParser"), with all its
|
||||
# qualifiers/annotations.
|
||||
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||
|
||||
m4_define([b4_parser_class_declaration],
|
||||
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||
[class ]b4_parser_class[]dnl
|
||||
b4_percent_define_if_get2([api.parser.extends], [api.parser.implements], [ : ])dnl
|
||||
b4_percent_define_get([api.parser.extends])dnl
|
||||
b4_percent_define_class_before_interface([api.parser.extends], [api.parser.implements])dnl
|
||||
b4_percent_define_get([api.parser.implements])])
|
||||
|
||||
|
||||
# b4_lexer_if(TRUE, FALSE)
|
||||
# ------------------------
|
||||
m4_define([b4_lexer_if],
|
||||
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_position_type_if(TRUE, FALSE)
|
||||
# --------------------------------
|
||||
m4_define([b4_position_type_if],
|
||||
[b4_percent_define_ifdef([[position_type]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_location_type_if(TRUE, FALSE)
|
||||
# --------------------------------
|
||||
m4_define([b4_location_type_if],
|
||||
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_identification
|
||||
# -----------------
|
||||
m4_define([b4_identification],
|
||||
[[/** Version number for the Bison executable that generated this parser. */
|
||||
public static immutable string yy_bison_version = "]b4_version_string[";
|
||||
|
||||
/** Name of the skeleton that generated this parser. */
|
||||
public static immutable string yy_bison_skeleton = ]b4_skeleton[;
|
||||
]])
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data types. ##
|
||||
## ------------ ##
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
[int])])
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# `NAME_min' to `NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
# b4_null
|
||||
# -------
|
||||
m4_define([b4_null], [null])
|
||||
|
||||
|
||||
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
||||
#-----------------------------------------------------
|
||||
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
||||
m4_define([b4_integral_parser_table_define],
|
||||
[m4_ifvaln([$3], [b4_comment([$3], [ ])])dnl
|
||||
private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
||||
@{
|
||||
$2
|
||||
@};dnl
|
||||
])
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
m4_define([b4_symbol(-2, id)], [[YYEMPTY]])
|
||||
b4_percent_define_default([[api.token.raw]], [[true]])
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_format([ %s = %s,
|
||||
], [$1])])
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[/* Token kinds. */
|
||||
public enum TokenKind {
|
||||
]b4_symbol(empty, id)[ = -2,
|
||||
b4_symbol_foreach([b4_token_enum])dnl
|
||||
}
|
||||
])
|
||||
|
||||
# b4_symbol_translate(STRING)
|
||||
# ---------------------------
|
||||
# Used by "bison" in the array of symbol names to mark those that
|
||||
# require translation.
|
||||
m4_define([b4_symbol_translate],
|
||||
[[_($1)]])
|
||||
|
||||
|
||||
# _b4_token_constructor_define(SYMBOL-NUM)
|
||||
# ----------------------------------------
|
||||
# Define Symbol.FOO for SYMBOL-NUM.
|
||||
m4_define([_b4_token_constructor_define],
|
||||
[b4_token_visible_if([$1],
|
||||
[[
|
||||
static auto ]b4_symbol([$1], [id])[(]b4_symbol_if([$1], [has_type],
|
||||
[b4_union_if([b4_symbol([$1], [type]],
|
||||
[[typeof(YYSemanticType.]b4_symbol([$1], [type])[]])) [val]])dnl
|
||||
[]b4_locations_if([b4_symbol_if([$1], [has_type], [[, ]])[Location l]])[)
|
||||
{
|
||||
return Symbol(TokenKind.]b4_symbol([$1], [id])[]b4_symbol_if([$1], [has_type],
|
||||
[[, val]])[]b4_locations_if([[, l]])[);
|
||||
}]])])
|
||||
|
||||
# b4_token_constructor_define
|
||||
# ---------------------------
|
||||
# Define Symbol.FOO for each token kind FOO.
|
||||
m4_define([b4_token_constructor_define],
|
||||
[[
|
||||
/* Implementation of token constructors for each symbol type visible to
|
||||
* the user. The code generates static methods that have the same names
|
||||
* as the TokenKinds.
|
||||
*/]b4_symbol_foreach([_b4_token_constructor_define])dnl
|
||||
])
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_symbol_kind(NUM)
|
||||
# -------------------
|
||||
m4_define([b4_symbol_kind],
|
||||
[SymbolKind.b4_symbol_kind_base($@)])
|
||||
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s = %s,]],
|
||||
b4_symbol([$1], [kind_base]),
|
||||
[$1]),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ /* Symbol kinds. */
|
||||
struct SymbolKind
|
||||
{
|
||||
enum
|
||||
{
|
||||
]b4_symbol(empty, kind_base)[ = -2, /* No symbol. */
|
||||
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||
[ }
|
||||
|
||||
private int yycode_;
|
||||
alias yycode_ this;
|
||||
|
||||
this(int code)
|
||||
{
|
||||
yycode_ = code;
|
||||
}
|
||||
|
||||
/* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
that double-quoting is unnecessary unless the string contains an
|
||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||
YYSTR is taken from yytname. */
|
||||
final void toString(W)(W sink) const
|
||||
if (isOutputRange!(W, char))
|
||||
{
|
||||
immutable string[] yy_sname = @{
|
||||
]b4_symbol_names[
|
||||
@};]b4_has_translations_if([[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||
internationalizable. */
|
||||
immutable ]b4_int_type_for([b4_translatable])[[] yytranslatable = @{
|
||||
]b4_translatable[
|
||||
@};]])[
|
||||
|
||||
put(sink, yy_sname[yycode_]);
|
||||
}
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
# b4_case(ID, CODE, [COMMENTS])
|
||||
# -----------------------------
|
||||
m4_define([b4_case], [ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
||||
$2
|
||||
break;])
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
||||
b4_percent_define_default([[stype]], [[YYSemanticType]])])
|
||||
|
||||
# %name-prefix
|
||||
m4_define_default([b4_prefix], [[YY]])
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])])
|
||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
#b4_percent_define_default([[location_type]], [Location])])
|
||||
m4_define([b4_location_type], b4_percent_define_ifdef([[location_type]],[b4_percent_define_get([[location_type]])],[YYLocation]))
|
||||
|
||||
#b4_percent_define_default([[position_type]], [Position])])
|
||||
m4_define([b4_position_type], b4_percent_define_ifdef([[position_type]],[b4_percent_define_get([[position_type]])],[YYPosition]))
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## api.value.type. ##
|
||||
## ---------------- ##
|
||||
|
||||
|
||||
# ---------------------- #
|
||||
# api.value.type=union. #
|
||||
# ---------------------- #
|
||||
|
||||
# b4_symbol_type_register(SYMBOL-NUM)
|
||||
# -----------------------------------
|
||||
# Symbol SYMBOL-NUM has a type (for union) instead of a type-tag.
|
||||
# Extend the definition of %union's body (b4_union_members) with a
|
||||
# field of that type, and extend the symbol's "type" field to point to
|
||||
# the field name, instead of the type name.
|
||||
m4_define([b4_symbol_type_register],
|
||||
[m4_define([b4_symbol($1, type_tag)],
|
||||
[b4_symbol_if([$1], [has_id],
|
||||
[b4_symbol([$1], [id])],
|
||||
[yykind_[]b4_symbol([$1], [number])])])dnl
|
||||
m4_append([b4_union_members],
|
||||
m4_expand([m4_format([ %-40s %s],
|
||||
m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]),
|
||||
[b4_symbol_tag_comment([$1])])]))
|
||||
])
|
||||
|
||||
|
||||
# b4_type_define_tag(SYMBOL1-NUM, ...)
|
||||
# ------------------------------------
|
||||
# For the batch of symbols SYMBOL1-NUM... (which all have the same
|
||||
# type), enhance the %union definition for each of them, and set
|
||||
# there "type" field to the field tag name, instead of the type name.
|
||||
m4_define([b4_type_define_tag],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[m4_map([b4_symbol_type_register], [$@])])
|
||||
])
|
||||
|
||||
|
||||
# b4_symbol_value_union(VAL, SYMBOL-NUM, [TYPE])
|
||||
# ----------------------------------------------
|
||||
# Same of b4_symbol_value, but when api.value.type=union.
|
||||
m4_define([b4_symbol_value_union],
|
||||
[m4_ifval([$3],
|
||||
[(*($3*)(&$1))],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[($1.b4_symbol([$2], [type_tag]))],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
|
||||
# b4_value_type_setup_union
|
||||
# -------------------------
|
||||
# Setup support for api.value.type=union. Symbols are defined with a
|
||||
# type instead of a union member name: build the corresponding union,
|
||||
# and give the symbols their tag.
|
||||
m4_define([b4_value_type_setup_union],
|
||||
[m4_define([b4_union_members])
|
||||
b4_type_foreach([b4_type_define_tag])
|
||||
m4_copy_force([b4_symbol_value_union], [b4_symbol_value])
|
||||
])
|
||||
|
||||
|
||||
# _b4_value_type_setup_keyword
|
||||
# ----------------------------
|
||||
# api.value.type is defined with a keyword/string syntax. Check if
|
||||
# that is properly defined, and prepare its use.
|
||||
m4_define([_b4_value_type_setup_keyword],
|
||||
[b4_percent_define_check_values([[[[api.value.type]],
|
||||
[[none]],
|
||||
[[union]],
|
||||
[[union-directive]],
|
||||
[[yystype]]]])dnl
|
||||
m4_case(b4_percent_define_get([[api.value.type]]),
|
||||
[union], [b4_value_type_setup_union])])
|
||||
|
||||
|
||||
# b4_value_type_setup
|
||||
# -------------------
|
||||
# Check if api.value.type is properly defined, and possibly prepare
|
||||
# its use.
|
||||
b4_define_silent([b4_value_type_setup],
|
||||
[
|
||||
# Define default value.
|
||||
b4_percent_define_ifdef([[api.value.type]], [],
|
||||
[# %union => api.value.type=union-directive
|
||||
m4_ifdef([b4_union_members],
|
||||
[m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
||||
m4_define([b4_percent_define(api.value.type)], [union-directive])],
|
||||
[# no tag seen => api.value.type={int}
|
||||
m4_if(b4_tag_seen_flag, 0,
|
||||
[m4_define([b4_percent_define_kind(api.value.type)], [code])
|
||||
m4_define([b4_percent_define(api.value.type)], [int])],
|
||||
[# otherwise api.value.type=yystype
|
||||
m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
||||
m4_define([b4_percent_define(api.value.type)], [yystype])])])])
|
||||
|
||||
# Set up.
|
||||
m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
||||
[keyword], [_b4_value_type_setup_keyword])
|
||||
])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||
# ----------------------------------------------
|
||||
# See README. FIXME: factor in c-like?
|
||||
m4_define([b4_symbol_value],
|
||||
[m4_ifval([$3],
|
||||
[($1.$3)],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[($1.b4_symbol([$2], [type]))],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
# b4_lhs_value(SYMBOL-NUM, [TYPE])
|
||||
# --------------------------------
|
||||
# See README.
|
||||
m4_define([b4_lhs_value],
|
||||
[b4_symbol_value([yyval], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
||||
# --------------------------------------------------
|
||||
# See README.
|
||||
#
|
||||
# In this simple implementation, %token and %type have class names
|
||||
# between the angle brackets.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([(yystack.valueAt (b4_subtract([$1], [$2])))], [$3], [$4])])
|
||||
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[yystack.locationAt (b4_subtract($@))])
|
||||
|
||||
|
||||
# b4_lex_param
|
||||
# b4_parse_param
|
||||
# --------------
|
||||
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
||||
# it to be single quoted. Same for b4_parse_param.
|
||||
|
||||
# TODO: should be in bison.m4
|
||||
m4_define_default([b4_lex_param], [[]]))
|
||||
m4_define([b4_lex_param], b4_lex_param))
|
||||
m4_define([b4_parse_param], b4_parse_param))
|
||||
|
||||
# b4_lex_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_lex_param_decl],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_lex_param))],
|
||||
[$1])])
|
||||
|
||||
m4_define([b4_param_decls],
|
||||
[m4_map([b4_param_decl], [$@])])
|
||||
m4_define([b4_param_decl], [, $1])
|
||||
|
||||
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_parse_param_decl],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_parse_param))],
|
||||
[$1])])
|
||||
|
||||
|
||||
|
||||
# b4_lex_param_call
|
||||
# -------------------
|
||||
# Delegating the lexer parameters to the lexer constructor.
|
||||
m4_define([b4_lex_param_call],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_calls(b4_lex_param))],
|
||||
[$1])])
|
||||
m4_define([b4_param_calls],
|
||||
[m4_map([b4_param_call], [$@])])
|
||||
m4_define([b4_param_call], [, $2])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_cons
|
||||
# -------------------
|
||||
# Extra initialisations of the constructor.
|
||||
m4_define([b4_parse_param_cons],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_constructor_calls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_constructor_calls],
|
||||
[m4_map([b4_constructor_call], [$@])])
|
||||
m4_define([b4_constructor_call],
|
||||
[this.$2 = $2;
|
||||
])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_vars
|
||||
# -------------------
|
||||
# Extra instance variables.
|
||||
m4_define([b4_parse_param_vars],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
/* User arguments. */
|
||||
b4_var_decls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_var_decls],
|
||||
[m4_map_sep([b4_var_decl], [
|
||||
], [$@])])
|
||||
m4_define([b4_var_decl],
|
||||
[ protected $1;])
|
||||
|
||||
|
||||
# b4_public_types_declare
|
||||
# -----------------------
|
||||
# Define the public types: token, semantic value, location, and so forth.
|
||||
# Depending on %define token_lex, may be output in the header or source file.
|
||||
m4_define([b4_public_types_declare],
|
||||
[[
|
||||
alias Symbol = ]b4_parser_class[.Symbol;
|
||||
alias Value = ]b4_yystype[;]b4_locations_if([[
|
||||
alias Location = ]b4_location_type[;
|
||||
alias Position = ]b4_position_type[;]b4_push_if([[
|
||||
alias PUSH_MORE = ]b4_parser_class[.YYPUSH_MORE;
|
||||
alias ABORT = ]b4_parser_class[.YYABORT;
|
||||
alias ACCEPT = ]b4_parser_class[.YYACCEPT;]])[]])[
|
||||
]])
|
||||
|
||||
|
||||
# b4_basic_symbol_constructor_define
|
||||
# ----------------------------------
|
||||
# Create Symbol struct constructors for all the visible types.
|
||||
m4_define([b4_basic_symbol_constructor_define],
|
||||
[b4_token_visible_if([$1],
|
||||
[[ this(TokenKind token]b4_symbol_if([$1], [has_type],
|
||||
[[, ]b4_union_if([], [[typeof(YYSemanticType.]])b4_symbol([$1], [type])dnl
|
||||
[]b4_union_if([], [[) ]])[ val]])[]b4_locations_if([[, Location loc]])[)
|
||||
{
|
||||
kind = yytranslate_(token);]b4_union_if([b4_symbol_if([$1], [has_type], [[
|
||||
static foreach (member; __traits(allMembers, YYSemanticType))
|
||||
{
|
||||
static if (is(typeof(mixin("value_." ~ member)) == ]b4_symbol([$1], [type])[))
|
||||
{
|
||||
mixin("value_." ~ member ~ " = val;");
|
||||
}
|
||||
}]])], [b4_symbol_if([$1], [has_type], [[
|
||||
value_.]b4_symbol([$1], [type])[ = val;]])])[]b4_locations_if([
|
||||
location_ = loc;])[
|
||||
}
|
||||
]])])
|
||||
|
||||
|
||||
# b4_symbol_type_define
|
||||
# ---------------------
|
||||
# Define symbol_type, the external type for symbols used for symbol
|
||||
# constructors.
|
||||
m4_define([b4_symbol_type_define],
|
||||
[[
|
||||
/**
|
||||
* A complete symbol
|
||||
*/
|
||||
struct Symbol
|
||||
{
|
||||
private SymbolKind kind;
|
||||
private Value value_;]b4_locations_if([[
|
||||
private Location location_;]])[
|
||||
|
||||
]b4_type_foreach([b4_basic_symbol_constructor_define])[
|
||||
SymbolKind token() { return kind; }
|
||||
Value value() { return value_; }]b4_locations_if([[
|
||||
Location location() { return location_; }]])[
|
||||
]b4_token_ctor_if([b4_token_constructor_define])[
|
||||
}
|
||||
]])
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,395 @@
|
|||
#C++ GLR skeleton for Bison
|
||||
|
||||
#Copyright(C) 2002 - 2015, 2018 - 2021 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 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
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
#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, see < https: // www.gnu.org/licenses/>.
|
||||
|
||||
#This skeleton produces a C++ class that encapsulates a C glr parser.
|
||||
#This is in order to reduce the maintenance burden.The glr.c
|
||||
#skeleton is clean and pure enough so that there are no real
|
||||
#problems.The C++ interface is the same as that of lalr1.cc.In
|
||||
#fact, glr.c can replace yacc.c without the user noticing any
|
||||
#difference, and similarly for glr.cc replacing lalr1.cc.
|
||||
#
|
||||
#The passing of parse - params
|
||||
#
|
||||
#The additional arguments are stored as members of the parser
|
||||
#object, yyparser.The C routines need to carry yyparser
|
||||
#throughout the C parser; that's easy: make yyparser an
|
||||
#additional parse - param.But because the C++ skeleton needs to
|
||||
#know the "real" original parse - param, we save them
|
||||
#(b4_parse_param_orig).Note that b4_parse_param is overquoted
|
||||
#(and c.m4 strips one level of quotes).This is a PITA, and
|
||||
#explains why there are so many levels of quotes.
|
||||
#
|
||||
#The locations
|
||||
#
|
||||
#We use location.cc just like lalr1.cc, but because glr.c stores
|
||||
#the locations in a union, the position and location classes
|
||||
#must not have a constructor.Therefore, contrary to lalr1.cc, we
|
||||
#must not define "b4_location_constructors".As a consequence the
|
||||
#user must initialize the first positions(in particular the
|
||||
#filename member).
|
||||
|
||||
#We require a pure interface.
|
||||
m4_define([b4_pure_flag], [1])
|
||||
|
||||
m4_include(b4_skeletonsdir/[c++.m4])
|
||||
b4_bison_locations_if([m4_include(b4_skeletonsdir/[location.cc])])
|
||||
|
||||
m4_define([b4_parser_class],
|
||||
[b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
#Save the parse parameters.
|
||||
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
||||
|
||||
#b4_parse_param_wrap
|
||||
#-- -- -- -- -- -- -- -- -- -
|
||||
#New ones.
|
||||
m4_ifset([b4_parse_param],
|
||||
[m4_define([b4_parse_param_wrap],
|
||||
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]],]
|
||||
m4_defn([b4_parse_param]))],
|
||||
[m4_define([b4_parse_param_wrap],
|
||||
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
|
||||
])
|
||||
|
||||
#b4_yy_symbol_print_define
|
||||
#-- -- -- -- -- -- -- -- -- -- -- -- -
|
||||
#Bypass the default implementation to generate the "yy_symbol_print"
|
||||
# and "yy_symbol_value_print" functions.
|
||||
m4_define([b4_yy_symbol_print_define],
|
||||
[[/*--------------------.
|
||||
| Print this symbol. |
|
||||
`--------------------*/
|
||||
|
||||
static void
|
||||
yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken,
|
||||
const ]b4_namespace_ref::b4_parser_class[::value_type *yyvaluep]b4_locations_if([[,
|
||||
const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([, yylocationp])[);
|
||||
}
|
||||
]])[
|
||||
|
||||
#Hijack the initial action to initialize the locations.
|
||||
]b4_bison_locations_if([m4_define([b4_initial_action],
|
||||
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
|
||||
m4_defn([b4_initial_action])]))])[
|
||||
|
||||
#Hijack the post prologue to declare yyerror.
|
||||
]m4_append([b4_post_prologue],
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
[static void
|
||||
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||
])[const char* msg);]])[
|
||||
|
||||
#Inserted before the epilogue to define implementations(yyerror, parser member
|
||||
#functions etc.).
|
||||
]m4_define([b4_glr_cc_pre_epilogue],
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
[
|
||||
/*------------------.
|
||||
| Report an error. |
|
||||
`------------------*/
|
||||
|
||||
static void
|
||||
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||
])[const char* msg)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
||||
}
|
||||
|
||||
|
||||
]b4_namespace_open[
|
||||
]dnl In this section, the parse params are the original parse_params.
|
||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
[ /// Build a parser object.
|
||||
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||
:])[
|
||||
#if] b4_api_PREFIX[DEBUG
|
||||
]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||
#endif] b4_parse_param_cons[
|
||||
{}
|
||||
|
||||
]b4_parser_class::~b4_parser_class[ ()
|
||||
{}
|
||||
|
||||
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
||||
{}
|
||||
|
||||
int
|
||||
]b4_parser_class[::operator() ()
|
||||
{
|
||||
return parse();
|
||||
}
|
||||
|
||||
int
|
||||
]b4_parser_class[::parse ()
|
||||
{
|
||||
return ::yy_parse_impl (*this]b4_user_args[);
|
||||
}
|
||||
|
||||
#if] b4_api_PREFIX[DEBUG
|
||||
/*--------------------.
|
||||
| Print this symbol. |
|
||||
`--------------------*/
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{]b4_locations_if([[
|
||||
YY_USE (yylocationp);]])[
|
||||
YY_USE (yyvaluep);
|
||||
std::ostream& yyo = debug_stream ();
|
||||
std::ostream& yyoutput = yyo;
|
||||
YY_USE (yyoutput);
|
||||
]b4_symbol_actions([printer])[
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{
|
||||
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yysymbol_name (yykind) << " ("]b4_locations_if([[
|
||||
<< *yylocationp << ": "]])[;
|
||||
yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
||||
*yycdebug_ << ')';
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
]b4_parser_class[::debug_stream () const
|
||||
{
|
||||
return *yycdebug_;
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class[::set_debug_stream (std::ostream& o)
|
||||
{
|
||||
yycdebug_ = &o;
|
||||
}
|
||||
|
||||
|
||||
]b4_parser_class[::debug_level_type
|
||||
]b4_parser_class[::debug_level () const
|
||||
{
|
||||
return yydebug;
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class[::set_debug_level (debug_level_type l)
|
||||
{
|
||||
// Actually, it is yydebug which is really used.
|
||||
yydebug = l;
|
||||
}
|
||||
|
||||
#endif
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
b4_namespace_close[]dnl
|
||||
])
|
||||
|
||||
|
||||
m4_define([b4_define_symbol_kind],
|
||||
[m4_format([#define %-15s %s],
|
||||
b4_symbol($][1, kind_base),
|
||||
b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol($1, kind_base))
|
||||
])
|
||||
|
||||
#b4_glr_cc_setup
|
||||
#-- -- -- -- -- -- -- -
|
||||
#Setup redirections for glr.c : Map the names used in c.m4 to the ones used
|
||||
#in c++.m4.
|
||||
m4_define([b4_glr_cc_setup],
|
||||
[[]b4_attribute_define[
|
||||
]b4_null_define[
|
||||
|
||||
// This skeleton is based on C, yet compiles it as C++.
|
||||
// So expect warnings about C style casts.
|
||||
#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
|
||||
# pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#endif
|
||||
|
||||
// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
|
||||
// -pedantic reports as being a C++11 extension.
|
||||
#if defined __APPLE__ && YY_CPLUSPLUS < 201103L && defined __clang__ && 4 <= __clang_major__
|
||||
# pragma clang diagnostic ignored "-Wc++11-long-long"
|
||||
#endif
|
||||
|
||||
#undef] b4_symbol(empty, [id])[
|
||||
#define] b4_symbol(empty, [id])[] b4_namespace_ref[::] b4_parser_class[::token::] b4_symbol( \
|
||||
empty, [id])[
|
||||
#undef] b4_symbol(eof, [id])[
|
||||
#define] b4_symbol(eof, [id])[] b4_namespace_ref[::] b4_parser_class[::token::] b4_symbol( \
|
||||
eof, [id])[
|
||||
#undef] b4_symbol(error, [id])[
|
||||
#define] b4_symbol(error, [id])[] b4_namespace_ref[::] b4_parser_class[::token::] b4_symbol( \
|
||||
error, [id])[
|
||||
|
||||
#ifndef] b4_api_PREFIX[STYPE
|
||||
# define] b4_api_PREFIX[STYPE] b4_namespace_ref[::] b4_parser_class[::value_type
|
||||
#endif
|
||||
#ifndef] b4_api_PREFIX[LTYPE
|
||||
# define] b4_api_PREFIX[LTYPE] b4_namespace_ref[::] b4_parser_class[::location_type
|
||||
#endif
|
||||
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
|
||||
|
||||
// Expose C++ symbol kinds to C.
|
||||
]b4_define_symbol_kind(-2)dnl
|
||||
b4_symbol_foreach([b4_define_symbol_kind])])[
|
||||
]])
|
||||
|
||||
|
||||
m4_define([b4_undef_symbol_kind],
|
||||
[[#undef ]b4_symbol($1, kind_base)[
|
||||
]])
|
||||
|
||||
#b4_glr_cc_cleanup
|
||||
#-- -- -- -- -- -- -- -- -
|
||||
#Remove redirections for glr.c.
|
||||
m4_define([b4_glr_cc_cleanup],
|
||||
[[#undef ]b4_symbol(empty, [id])[
|
||||
#undef] b4_symbol(eof, [id])[
|
||||
#undef] b4_symbol(error, [id])[
|
||||
|
||||
]b4_undef_symbol_kind(-2)dnl
|
||||
b4_symbol_foreach([b4_undef_symbol_kind])dnl
|
||||
])
|
||||
|
||||
#b4_shared_declarations(hh | cc)
|
||||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -
|
||||
#Declaration that might either go into the header(if --header, $1 = hh)
|
||||
# or in the implementation file.
|
||||
m4_define([b4_shared_declarations],
|
||||
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
b4_percent_code_get([[requires]])[
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
]b4_cxx_portability[
|
||||
]m4_ifdef([b4_location_include],
|
||||
[[# include ]b4_location_include])[
|
||||
]b4_variant_if([b4_variant_includes])[
|
||||
|
||||
// Whether we are compiled with exception support.
|
||||
#ifndef YY_EXCEPTIONS
|
||||
# if defined __GNUC__ && !defined __EXCEPTIONS
|
||||
# define YY_EXCEPTIONS 0
|
||||
# else
|
||||
# define YY_EXCEPTIONS 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
]b4_YYDEBUG_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
|
||||
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||
[b4_location_define])])[
|
||||
|
||||
/// A Bison parser.
|
||||
class ]b4_parser_class[
|
||||
{
|
||||
public:
|
||||
]b4_public_types_declare[
|
||||
|
||||
/// Build a parser object.
|
||||
]b4_parser_class[ (]b4_parse_param_decl[);
|
||||
virtual ~]b4_parser_class[ ();
|
||||
|
||||
/// Parse. An alias for parse ().
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
int operator() ();
|
||||
|
||||
/// Parse.
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
virtual int parse ();
|
||||
|
||||
#if] b4_api_PREFIX[DEBUG
|
||||
/// The current debugging stream.
|
||||
std::ostream& debug_stream () const;
|
||||
/// Set the current debugging stream.
|
||||
void set_debug_stream (std::ostream &);
|
||||
|
||||
/// Type for debugging levels.
|
||||
typedef int debug_level_type;
|
||||
/// The current debugging level.
|
||||
debug_level_type debug_level () const;
|
||||
/// Set the current debugging level.
|
||||
void set_debug_level (debug_level_type l);
|
||||
#endif
|
||||
|
||||
/// Report a syntax error.]b4_locations_if([[
|
||||
/// \param loc where the syntax error is found.]])[
|
||||
/// \param msg a description of the syntax error.
|
||||
virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
|
||||
|
||||
#if] b4_api_PREFIX[DEBUG
|
||||
public:
|
||||
/// \brief Report a symbol value on the debug stream.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
private:
|
||||
/// Debug stream.
|
||||
std::ostream* yycdebug_;
|
||||
#endif
|
||||
|
||||
]b4_parse_param_vars[
|
||||
};
|
||||
|
||||
]b4_namespace_close[
|
||||
|
||||
]b4_percent_code_get([[provides]])[
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
])[
|
||||
|
||||
]b4_header_if(
|
||||
[b4_output_begin([b4_spec_header_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
[2002-2015, 2018-2021])[
|
||||
// C++ GLR parser skeleton written by Akim Demaille.
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_cpp_guard_open([b4_spec_mapped_header_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_mapped_header_file])[
|
||||
]b4_output_end])
|
||||
|
||||
#Let glr.c(and b4_shared_declarations) believe that the user
|
||||
#arguments include the parser itself.
|
||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_wrap]))
|
||||
m4_include(b4_skeletonsdir/[glr.c])
|
||||
m4_popdef([b4_parse_param])
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,27 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# Java skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2007, 2009-2015, 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [b4_complain([%%glr-parser not supported for Java])])
|
||||
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for Java])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.java]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
|
@ -0,0 +1,502 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# Java language support for Bison
|
||||
|
||||
# Copyright (C) 2007-2015, 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
m4_include(b4_skeletonsdir/[c-like.m4])
|
||||
|
||||
|
||||
# b4_list2(LIST1, LIST2)
|
||||
# ----------------------
|
||||
# Join two lists with a comma if necessary.
|
||||
m4_define([b4_list2],
|
||||
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
||||
|
||||
|
||||
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
||||
# -------------------------------------------
|
||||
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
||||
# otherwise NOT.
|
||||
m4_define([b4_percent_define_get3],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
||||
|
||||
|
||||
|
||||
# b4_flag_value(BOOLEAN-FLAG)
|
||||
# ---------------------------
|
||||
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||
|
||||
|
||||
# b4_parser_class_declaration
|
||||
# ---------------------------
|
||||
# The declaration of the parser class ("class YYParser"), with all its
|
||||
# qualifiers/annotations.
|
||||
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||
b4_percent_define_default([[api.parser.strictfp]], [[false]])
|
||||
|
||||
m4_define([b4_parser_class_declaration],
|
||||
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||
b4_percent_define_flag_if([api.parser.strictfp], [strictfp ])dnl
|
||||
[class ]b4_parser_class[]dnl
|
||||
b4_percent_define_get3([api.parser.extends], [ extends ])dnl
|
||||
b4_percent_define_get3([api.parser.implements], [ implements ])])
|
||||
|
||||
|
||||
# b4_lexer_if(TRUE, FALSE)
|
||||
# ------------------------
|
||||
m4_define([b4_lexer_if],
|
||||
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_identification
|
||||
# -----------------
|
||||
m4_define([b4_identification],
|
||||
[[ /** Version number for the Bison executable that generated this parser. */
|
||||
public static final String bisonVersion = "]b4_version_string[";
|
||||
|
||||
/** Name of the skeleton that generated this parser. */
|
||||
public static final String bisonSkeleton = ]b4_skeleton[;
|
||||
]])
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data types. ##
|
||||
## ------------ ##
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
[int])])
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# 'NAME_min' to 'NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
# b4_null
|
||||
# -------
|
||||
m4_define([b4_null], [null])
|
||||
|
||||
|
||||
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
||||
# -------------------------------------------------------
|
||||
# We use intermediate functions (e.g., yypact_init) to work around the
|
||||
# 64KB limit for JVM methods. See
|
||||
# https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.
|
||||
m4_define([b4_typed_parser_table_define],
|
||||
[m4_ifval([$4], [b4_comment([$4])
|
||||
])dnl
|
||||
[private static final ]$1[[] yy$2_ = yy$2_init();
|
||||
private static final ]$1[[] yy$2_init()
|
||||
{
|
||||
return new ]$1[[]
|
||||
{
|
||||
]$3[
|
||||
};
|
||||
}]])
|
||||
|
||||
|
||||
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
||||
#-----------------------------------------------------
|
||||
m4_define([b4_integral_parser_table_define],
|
||||
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NUM)
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_format([[ /** Token %s, to be returned by the scanner. */
|
||||
static final int %s = %s%s;
|
||||
]],
|
||||
b4_symbol([$1], [tag]),
|
||||
b4_symbol([$1], [id]),
|
||||
b4_symbol([$1], b4_api_token_raw_if([[number]], [[code]])))])])
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[b4_any_token_visible_if([ /* Token kinds. */
|
||||
b4_symbol_foreach([b4_token_enum])])])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
|
||||
# b4_symbol_kind(NUM)
|
||||
# -------------------
|
||||
m4_define([b4_symbol_kind],
|
||||
[SymbolKind.b4_symbol_kind_base($@)])
|
||||
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s(%s)%s]],
|
||||
b4_symbol([$1], [kind_base]),
|
||||
[$1],
|
||||
m4_if([$1], b4_last_symbol, [[;]], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ public enum SymbolKind
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_enum])[
|
||||
|
||||
private final int yycode_;
|
||||
|
||||
SymbolKind (int n) {
|
||||
this.yycode_ = n;
|
||||
}
|
||||
|
||||
private static final SymbolKind[] values_ = {
|
||||
]m4_map_args_sep([b4_symbol_kind(], [)], [,
|
||||
], b4_symbol_numbers)[
|
||||
};
|
||||
|
||||
static final SymbolKind get(int code) {
|
||||
return values_[code];
|
||||
}
|
||||
|
||||
public final int getCode() {
|
||||
return this.yycode_;
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[simple\|verbose],
|
||||
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
that double-quoting is unnecessary unless the string contains an
|
||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||
YYSTR is taken from yytname. */
|
||||
private static String yytnamerr_(String yystr)
|
||||
{
|
||||
if (yystr.charAt (0) == '"')
|
||||
{
|
||||
StringBuffer yyr = new StringBuffer();
|
||||
strip_quotes: for (int i = 1; i < yystr.length(); i++)
|
||||
switch (yystr.charAt(i))
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
break strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (yystr.charAt(++i) != '\\')
|
||||
break strip_quotes;
|
||||
/* Fall through. */
|
||||
default:
|
||||
yyr.append(yystr.charAt(i));
|
||||
break;
|
||||
|
||||
case '"':
|
||||
return yyr.toString();
|
||||
}
|
||||
}
|
||||
return yystr;
|
||||
}
|
||||
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||
|
||||
/* The user-facing name of this symbol. */
|
||||
public final String getName() {
|
||||
return yytnamerr_(yytname_[yycode_]);
|
||||
}
|
||||
]],
|
||||
[custom\|detailed],
|
||||
[[ /* YYNAMES_[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [names], [b4_symbol_names])[
|
||||
|
||||
/* The user-facing name of this symbol. */
|
||||
public final String getName() {
|
||||
return yynames_[yycode_];
|
||||
}]])[
|
||||
};
|
||||
]])])
|
||||
|
||||
|
||||
|
||||
# b4_case(ID, CODE, [COMMENTS])
|
||||
# -----------------------------
|
||||
# We need to fool Java's stupid unreachable code detection.
|
||||
m4_define([b4_case],
|
||||
[ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
||||
if (yyn == $1)
|
||||
$2;
|
||||
break;
|
||||
])
|
||||
|
||||
|
||||
# b4_predicate_case(LABEL, CONDITIONS)
|
||||
# ------------------------------------
|
||||
m4_define([b4_predicate_case],
|
||||
[ case $1:
|
||||
if (! ($2)) YYERROR;
|
||||
break;
|
||||
])
|
||||
|
||||
|
||||
## -------- ##
|
||||
## Checks. ##
|
||||
## -------- ##
|
||||
|
||||
b4_percent_define_check_kind([[api.value.type]], [code], [deprecated])
|
||||
|
||||
b4_percent_define_check_kind([[annotations]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[extends]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[implements]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[api.parser.class]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
||||
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
||||
b4_percent_define_default([[api.value.type]], [[Object]])
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||
|
||||
# b4_api_prefix, b4_api_PREFIX
|
||||
# ----------------------------
|
||||
# Corresponds to %define api.prefix
|
||||
b4_percent_define_default([[api.prefix]], [[YY]])
|
||||
m4_define([b4_api_prefix],
|
||||
[b4_percent_define_get([[api.prefix]])])
|
||||
m4_define([b4_api_PREFIX],
|
||||
[m4_toupper(b4_api_prefix)])
|
||||
|
||||
# b4_prefix
|
||||
# ---------
|
||||
# If the %name-prefix is not given, it is api.prefix.
|
||||
m4_define_default([b4_prefix], [b4_api_prefix])
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])
|
||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])
|
||||
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
|
||||
|
||||
b4_percent_define_default([[throws]], [])
|
||||
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
||||
|
||||
b4_percent_define_default([[init_throws]], [])
|
||||
m4_define([b4_init_throws], [b4_percent_define_get([[init_throws]])])
|
||||
|
||||
b4_percent_define_default([[api.location.type]], [Location])
|
||||
m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])
|
||||
|
||||
b4_percent_define_default([[api.position.type]], [Position])
|
||||
m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
# b4_symbol_translate(STRING)
|
||||
# ---------------------------
|
||||
# Used by "bison" in the array of symbol names to mark those that
|
||||
# require translation.
|
||||
m4_define([b4_symbol_translate],
|
||||
[[i18n($1)]])
|
||||
|
||||
|
||||
# b4_trans(STRING)
|
||||
# ----------------
|
||||
# Translate a string if i18n is enabled. Avoid collision with b4_translate.
|
||||
m4_define([b4_trans],
|
||||
[b4_has_translations_if([i18n($1)], [$1])])
|
||||
|
||||
|
||||
|
||||
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||
# ----------------------------------------------
|
||||
# See README.
|
||||
m4_define([b4_symbol_value],
|
||||
[m4_ifval([$3],
|
||||
[(($3)($1))],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[((b4_symbol([$2], [type]))($1))],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
|
||||
# b4_lhs_value([SYMBOL-NUM], [TYPE])
|
||||
# ----------------------------------
|
||||
# See README.
|
||||
m4_define([b4_lhs_value], [yyval])
|
||||
|
||||
|
||||
# b4_rhs_data(RULE-LENGTH, POS)
|
||||
# -----------------------------
|
||||
# See README.
|
||||
m4_define([b4_rhs_data],
|
||||
[yystack.valueAt (b4_subtract($@))])
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
||||
# --------------------------------------------------
|
||||
# See README.
|
||||
#
|
||||
# In this simple implementation, %token and %type have class names
|
||||
# between the angle brackets.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([b4_rhs_data([$1], [$2])], [$3], [$4])])
|
||||
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[yystack.locationAt (b4_subtract($@))])
|
||||
|
||||
|
||||
# b4_lex_param
|
||||
# b4_parse_param
|
||||
# --------------
|
||||
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
||||
# it to be single quoted. Same for b4_parse_param.
|
||||
|
||||
# TODO: should be in bison.m4
|
||||
m4_define_default([b4_lex_param], [[]])
|
||||
m4_define([b4_lex_param], b4_lex_param)
|
||||
m4_define([b4_parse_param], b4_parse_param)
|
||||
|
||||
# b4_lex_param_decl
|
||||
# -----------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_lex_param_decl],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_lex_param))],
|
||||
[$1])])
|
||||
|
||||
m4_define([b4_param_decls],
|
||||
[m4_map([b4_param_decl], [$@])])
|
||||
m4_define([b4_param_decl], [, $1])
|
||||
|
||||
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_parse_param_decl],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_parse_param))],
|
||||
[$1])])
|
||||
|
||||
|
||||
|
||||
# b4_lex_param_call
|
||||
# -----------------
|
||||
# Delegating the lexer parameters to the lexer constructor.
|
||||
m4_define([b4_lex_param_call],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_calls(b4_lex_param))],
|
||||
[$1])])
|
||||
m4_define([b4_param_calls],
|
||||
[m4_map([b4_param_call], [$@])])
|
||||
m4_define([b4_param_call], [, $2])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_cons
|
||||
# -------------------
|
||||
# Extra initialisations of the constructor.
|
||||
m4_define([b4_parse_param_cons],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_constructor_calls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_constructor_calls],
|
||||
[m4_map([b4_constructor_call], [$@])])
|
||||
m4_define([b4_constructor_call],
|
||||
[this.$2 = $2;
|
||||
])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_vars
|
||||
# -------------------
|
||||
# Extra instance variables.
|
||||
m4_define([b4_parse_param_vars],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
/* User arguments. */
|
||||
b4_var_decls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_var_decls],
|
||||
[m4_map_sep([b4_var_decl], [
|
||||
], [$@])])
|
||||
m4_define([b4_var_decl],
|
||||
[ protected final $1;])
|
||||
|
||||
|
||||
|
||||
# b4_maybe_throws(THROWS)
|
||||
# -----------------------
|
||||
# Expand to either an empty string or "throws THROWS".
|
||||
m4_define([b4_maybe_throws],
|
||||
[m4_ifval($1, [ throws $1])])
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,371 @@
|
|||
#C++ skeleton for Bison
|
||||
|
||||
#Copyright(C) 2002 - 2015, 2018 - 2021 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 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
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
#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, see < https: // www.gnu.org/licenses/>.
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2015, 2018-2021])
|
||||
|
||||
#b4_location_file
|
||||
#-- -- -- -- -- -- -- --
|
||||
#Name of the file containing the position / location class,
|
||||
#if we want this file.
|
||||
b4_percent_define_check_file([b4_location_file],
|
||||
[[api.location.file]],
|
||||
b4_header_if([[location.hh]]))
|
||||
|
||||
# b4_location_include
|
||||
# -- -- -- -- -- -- -- -- -- -
|
||||
# If location.hh is to be generated, the name under which should it be
|
||||
# included.
|
||||
#
|
||||
# b4_location_path
|
||||
# -- -- -- -- -- -- -- --
|
||||
# The path to use for the CPP guard.
|
||||
m4_ifdef([b4_location_file],
|
||||
[m4_define([b4_location_include],
|
||||
[b4_percent_define_get([[api.location.include]],
|
||||
["b4_location_file"])])
|
||||
m4_define([b4_location_path],
|
||||
b4_percent_define_get([[api.location.include]],
|
||||
["b4_mapped_dir_prefix[]b4_location_file"]))
|
||||
m4_define([b4_location_path],
|
||||
m4_substr(m4_defn([b4_location_path]), 1, m4_eval(m4_len(m4_defn([b4_location_path])) - 2)))
|
||||
])
|
||||
|
||||
# b4_position_file
|
||||
# -- -- -- -- -- -- -- --
|
||||
# Name of the file containing the position class, if we want this file.
|
||||
b4_header_if(
|
||||
[b4_required_version_if(
|
||||
[30200], [],
|
||||
[m4_ifdef([b4_location_file],
|
||||
[m4_define([b4_position_file], [position.hh])])])])
|
||||
|
||||
# b4_location_define
|
||||
# -- -- -- -- -- -- -- -- --
|
||||
# Define the position and location classes.
|
||||
m4_define([b4_location_define],
|
||||
[[ /// A point in a source file.
|
||||
class position
|
||||
{
|
||||
public:
|
||||
/// Type for file name.
|
||||
typedef ]b4_percent_define_get([[api.filename.type]])[ filename_type;
|
||||
/// Type for line and column numbers.
|
||||
typedef int counter_type;
|
||||
]m4_ifdef([b4_location_constructors], [[
|
||||
/// Construct a position.
|
||||
explicit position (filename_type* f = YY_NULLPTR,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
: filename (f)
|
||||
, line (l)
|
||||
, column (c)
|
||||
{}
|
||||
|
||||
]])[
|
||||
/// Initialization.
|
||||
void initialize (filename_type* fn = YY_NULLPTR,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
{
|
||||
filename = fn;
|
||||
line = l;
|
||||
column = c;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
if (count)
|
||||
{
|
||||
column = ]b4_location_initial_column[;
|
||||
line = add_ (line, count, ]b4_location_initial_line[);
|
||||
}
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
column = add_ (column, count, ]b4_location_initial_column[);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
/// File name to which this position refers.
|
||||
filename_type* filename;
|
||||
/// Current line number.
|
||||
counter_type line;
|
||||
/// Current column number.
|
||||
counter_type column;
|
||||
|
||||
private:
|
||||
/// Compute max (min, lhs+rhs).
|
||||
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
|
||||
{
|
||||
return lhs + rhs < min ? min : lhs + rhs;
|
||||
}
|
||||
};
|
||||
|
||||
/// Add \a width columns, in place.
|
||||
inline position&
|
||||
operator+= (position& res, position::counter_type width)
|
||||
{
|
||||
res.columns(width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns.
|
||||
inline position
|
||||
operator+ (position res, position::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns, in place.
|
||||
inline position&
|
||||
operator-= (position& res, position::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns.
|
||||
inline position
|
||||
operator- (position res, position::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
]b4_percent_define_flag_if([[define_location_comparison]], [[
|
||||
/// Compare two position objects.
|
||||
inline bool
|
||||
operator== (const position& pos1, const position& pos2)
|
||||
{
|
||||
return (pos1.line == pos2.line && pos1.column == pos2.column &&
|
||||
(pos1.filename == pos2.filename ||
|
||||
(pos1.filename && pos2.filename && *pos1.filename == *pos2.filename)));
|
||||
}
|
||||
|
||||
/// Compare two position objects.
|
||||
inline bool
|
||||
operator!= (const position& pos1, const position& pos2)
|
||||
{
|
||||
return !(pos1 == pos2);
|
||||
}
|
||||
]])[
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param pos a reference to the position to redirect
|
||||
*/
|
||||
template <typename YYChar>
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
|
||||
{
|
||||
if (pos.filename)
|
||||
ostr << *pos.filename << ':';
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
|
||||
/// Two points in a source file.
|
||||
class location
|
||||
{
|
||||
public:
|
||||
/// Type for file name.
|
||||
typedef position::filename_type filename_type;
|
||||
/// Type for line and column numbers.
|
||||
typedef position::counter_type counter_type;
|
||||
]m4_ifdef([b4_location_constructors], [
|
||||
/// Construct a location from \a b to \a e.
|
||||
location (const position& b, const position& e)
|
||||
: begin (b)
|
||||
, end (e)
|
||||
{}
|
||||
|
||||
/// Construct a 0-width location in \a p.
|
||||
explicit location (const position& p = position ())
|
||||
: begin (p)
|
||||
, end (p)
|
||||
{}
|
||||
|
||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||
explicit location (filename_type* f,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
: begin (f, l, c)
|
||||
, end (f, l, c)
|
||||
{}
|
||||
|
||||
])[
|
||||
/// Initialization.
|
||||
void initialize (filename_type* f = YY_NULLPTR,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
{
|
||||
begin.initialize(f, l, c);
|
||||
end = begin;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// Reset initial location to final location.
|
||||
void step ()
|
||||
{
|
||||
begin = end;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next columns.
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
end += count;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next lines.
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
end.lines(count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
||||
public:
|
||||
/// Beginning of the located region.
|
||||
position begin;
|
||||
/// End of the located region.
|
||||
position end;
|
||||
};
|
||||
|
||||
/// Join two locations, in place.
|
||||
inline location&
|
||||
operator+= (location& res, const location& end)
|
||||
{
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Join two locations.
|
||||
inline location
|
||||
operator+ (location res, const location& end)
|
||||
{
|
||||
return res += end;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position, in place.
|
||||
inline location&
|
||||
operator+= (location& res, location::counter_type width)
|
||||
{
|
||||
res.columns(width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position.
|
||||
inline location
|
||||
operator+ (location res, location::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position, in place.
|
||||
inline location&
|
||||
operator-= (location& res, location::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position.
|
||||
inline location
|
||||
operator- (location res, location::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
]b4_percent_define_flag_if([[define_location_comparison]], [[
|
||||
/// Compare two location objects.
|
||||
inline bool
|
||||
operator== (const location& loc1, const location& loc2)
|
||||
{
|
||||
return loc1.begin == loc2.begin && loc1.end == loc2.end;
|
||||
}
|
||||
|
||||
/// Compare two location objects.
|
||||
inline bool
|
||||
operator!= (const location& loc1, const location& loc2)
|
||||
{
|
||||
return !(loc1 == loc2);
|
||||
}
|
||||
]])[
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param loc a reference to the location to redirect
|
||||
**
|
||||
** Avoid duplicate information.
|
||||
*/
|
||||
template <typename YYChar>
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||
{
|
||||
location::counter_type end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename && (!loc.begin.filename || *loc.begin.filename != *loc.end.filename))
|
||||
ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.line < loc.end.line)
|
||||
ostr << '-' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.column < end_col)
|
||||
ostr << '-' << end_col;
|
||||
return ostr;
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
m4_ifdef([b4_position_file], [[
|
||||
]b4_output_begin([b4_dir_prefix], [b4_position_file])[
|
||||
]b4_generated_by[
|
||||
// Starting with Bison 3.2, this file is useless: the structure it
|
||||
// used to define is now defined in "]b4_location_file[".
|
||||
//
|
||||
// To get rid of this file:
|
||||
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||
// 2. remove references to this file from your build system
|
||||
// 3. if you used to include it, include "]b4_location_file[" instead.
|
||||
|
||||
# include] b4_location_include[
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
|
||||
m4_ifdef([b4_location_file], [[
|
||||
]b4_output_begin([b4_dir_prefix], [b4_location_file])[
|
||||
]b4_copyright([Locations for Bison parsers in C++])[
|
||||
/**
|
||||
** \file ]b4_location_path[
|
||||
** Define the ]b4_namespace_ref[::location class.
|
||||
*/
|
||||
|
||||
]b4_cpp_guard_open([b4_location_path])[
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
]b4_null_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
]b4_location_define[
|
||||
]b4_namespace_close[
|
||||
]b4_cpp_guard_close([b4_location_path])[
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
|
||||
m4_popdef([b4_copyright_years])
|
|
@ -0,0 +1,157 @@
|
|||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# b4_stack_file
|
||||
# -------------
|
||||
# Name of the file containing the stack class, if we want this file.
|
||||
b4_header_if([b4_required_version_if([30200], [],
|
||||
[m4_define([b4_stack_file], [stack.hh])])])
|
||||
|
||||
|
||||
# b4_stack_define
|
||||
# ---------------
|
||||
m4_define([b4_stack_define],
|
||||
[[ /// A stack with random access from its top.
|
||||
template <typename T, typename S = std::vector<T> >
|
||||
class stack
|
||||
{
|
||||
public:
|
||||
// Hide our reversed order.
|
||||
typedef typename S::iterator iterator;
|
||||
typedef typename S::const_iterator const_iterator;
|
||||
typedef typename S::size_type size_type;
|
||||
typedef typename std::ptrdiff_t index_type;
|
||||
|
||||
stack (size_type n = 200) YY_NOEXCEPT
|
||||
: seq_ (n)
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
stack (const stack&) = delete;
|
||||
/// Non copyable.
|
||||
stack& operator= (const stack&) = delete;
|
||||
#endif
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
const T&
|
||||
operator[] (index_type i) const
|
||||
{
|
||||
return seq_[size_type (size () - 1 - i)];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
T&
|
||||
operator[] (index_type i)
|
||||
{
|
||||
return seq_[size_type (size () - 1 - i)];
|
||||
}
|
||||
|
||||
/// Steal the contents of \a t.
|
||||
///
|
||||
/// Close to move-semantics.
|
||||
void
|
||||
push (YY_MOVE_REF (T) t)
|
||||
{
|
||||
seq_.push_back (T ());
|
||||
operator[] (0).move (t);
|
||||
}
|
||||
|
||||
/// Pop elements from the stack.
|
||||
void
|
||||
pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
|
||||
{
|
||||
for (; 0 < n; --n)
|
||||
seq_.pop_back ();
|
||||
}
|
||||
|
||||
/// Pop all elements from the stack.
|
||||
void
|
||||
clear () YY_NOEXCEPT
|
||||
{
|
||||
seq_.clear ();
|
||||
}
|
||||
|
||||
/// Number of elements on the stack.
|
||||
index_type
|
||||
size () const YY_NOEXCEPT
|
||||
{
|
||||
return index_type (seq_.size ());
|
||||
}
|
||||
|
||||
/// Iterator on top of the stack (going downwards).
|
||||
const_iterator
|
||||
begin () const YY_NOEXCEPT
|
||||
{
|
||||
return seq_.begin ();
|
||||
}
|
||||
|
||||
/// Bottom of the stack.
|
||||
const_iterator
|
||||
end () const YY_NOEXCEPT
|
||||
{
|
||||
return seq_.end ();
|
||||
}
|
||||
|
||||
/// Present a slice of the top of a stack.
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
slice (const stack& stack, index_type range) YY_NOEXCEPT
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{}
|
||||
|
||||
const T&
|
||||
operator[] (index_type i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
const stack& stack_;
|
||||
index_type range_;
|
||||
};
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
stack (const stack&);
|
||||
/// Non copyable.
|
||||
stack& operator= (const stack&);
|
||||
#endif
|
||||
/// The wrapped container.
|
||||
S seq_;
|
||||
};
|
||||
]])
|
||||
|
||||
m4_ifdef([b4_stack_file],
|
||||
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
|
||||
]b4_generated_by[
|
||||
// Starting with Bison 3.2, this file is useless: the structure it
|
||||
// used to define is now defined with the parser itself.
|
||||
//
|
||||
// To get rid of this file:
|
||||
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||
// 2. remove references to this file from your build system.
|
||||
]b4_output_end[
|
||||
]])
|
|
@ -0,0 +1,2 @@
|
|||
dnl GNU M4 treats -dV in a position-independent manner.
|
||||
m4_debugmode(V)m4_traceon()dnl
|
|
@ -0,0 +1,525 @@
|
|||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2021 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 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
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
## --------- ##
|
||||
## variant. ##
|
||||
## --------- ##
|
||||
|
||||
# b4_assert
|
||||
# ---------
|
||||
# The name of YY_ASSERT.
|
||||
m4_define([b4_assert],
|
||||
[b4_api_PREFIX[]_ASSERT])
|
||||
|
||||
|
||||
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
|
||||
# ------------------------------------------------
|
||||
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
||||
# YYTYPE.
|
||||
m4_define([b4_symbol_variant],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
||||
switch ($1)
|
||||
{
|
||||
b4_type_foreach([_b4_type_action])[]dnl
|
||||
default:
|
||||
break;
|
||||
}
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
])
|
||||
|
||||
|
||||
# _b4_char_sizeof_counter
|
||||
# -----------------------
|
||||
# A counter used by _b4_char_sizeof_dummy to create fresh symbols.
|
||||
m4_define([_b4_char_sizeof_counter],
|
||||
[0])
|
||||
|
||||
# _b4_char_sizeof_dummy
|
||||
# ---------------------
|
||||
# At each call return a new C++ identifier.
|
||||
m4_define([_b4_char_sizeof_dummy],
|
||||
[m4_define([_b4_char_sizeof_counter], m4_incr(_b4_char_sizeof_counter))dnl
|
||||
dummy[]_b4_char_sizeof_counter])
|
||||
|
||||
|
||||
# b4_char_sizeof(SYMBOL-NUMS)
|
||||
# ---------------------------
|
||||
# To be mapped on the list of type names to produce:
|
||||
#
|
||||
# char dummy1[sizeof (type_name_1)];
|
||||
# char dummy2[sizeof (type_name_2)];
|
||||
#
|
||||
# for defined type names.
|
||||
m4_define([b4_char_sizeof],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[
|
||||
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
||||
char _b4_char_sizeof_dummy@{sizeof (b4_symbol([$1], [type]))@};
|
||||
])])
|
||||
|
||||
|
||||
# b4_variant_includes
|
||||
# -------------------
|
||||
# The needed includes for variants support.
|
||||
m4_define([b4_variant_includes],
|
||||
[b4_parse_assert_if([[#include <typeinfo>
|
||||
#ifndef ]b4_assert[
|
||||
# include <cassert>
|
||||
# define ]b4_assert[ assert
|
||||
#endif
|
||||
]])])
|
||||
|
||||
|
||||
|
||||
## -------------------------- ##
|
||||
## Adjustments for variants. ##
|
||||
## -------------------------- ##
|
||||
|
||||
|
||||
# b4_value_type_declare
|
||||
# ---------------------
|
||||
# Define value_type.
|
||||
m4_define([b4_value_type_declare],
|
||||
[[ /// A buffer to store and retrieve objects.
|
||||
///
|
||||
/// Sort of a variant, but does not keep track of the nature
|
||||
/// of the stored data, since that knowledge is available
|
||||
/// via the current parser state.
|
||||
class value_type
|
||||
{
|
||||
public:
|
||||
/// Type of *this.
|
||||
typedef value_type self_type;
|
||||
|
||||
/// Empty construction.
|
||||
value_type () YY_NOEXCEPT
|
||||
: yyraw_ ()]b4_parse_assert_if([
|
||||
, yytypeid_ (YY_NULLPTR)])[
|
||||
{}
|
||||
|
||||
/// Construct and fill.
|
||||
template <typename T>
|
||||
value_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||
: yytypeid_ (&typeid (T))])[
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (sizeof (T) <= size);]])[
|
||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||
}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
value_type (const self_type&) = delete;
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&) = delete;
|
||||
#endif
|
||||
|
||||
/// Destruction, allowed only if empty.
|
||||
~value_type () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
]b4_assert[ (!yytypeid_);
|
||||
])[}
|
||||
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
template <typename T, typename... U>
|
||||
T&
|
||||
emplace (U&&... u)
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (!yytypeid_);
|
||||
]b4_assert[ (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);]])[
|
||||
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
||||
}
|
||||
# else
|
||||
/// Instantiate an empty \a T in here.
|
||||
template <typename T>
|
||||
T&
|
||||
emplace ()
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (!yytypeid_);
|
||||
]b4_assert[ (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);]])[
|
||||
return *new (yyas_<T> ()) T ();
|
||||
}
|
||||
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
template <typename T>
|
||||
T&
|
||||
emplace (const T& t)
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (!yytypeid_);
|
||||
]b4_assert[ (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);]])[
|
||||
return *new (yyas_<T> ()) T (t);
|
||||
}
|
||||
# endif
|
||||
|
||||
/// Instantiate an empty \a T in here.
|
||||
/// Obsolete, use emplace.
|
||||
template <typename T>
|
||||
T&
|
||||
build ()
|
||||
{
|
||||
return emplace<T> ();
|
||||
}
|
||||
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
/// Obsolete, use emplace.
|
||||
template <typename T>
|
||||
T&
|
||||
build (const T& t)
|
||||
{
|
||||
return emplace<T> (t);
|
||||
}
|
||||
|
||||
/// Accessor to a built \a T.
|
||||
template <typename T>
|
||||
T&
|
||||
as () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (yytypeid_);
|
||||
]b4_assert[ (*yytypeid_ == typeid (T));
|
||||
]b4_assert[ (sizeof (T) <= size);]])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
/// Const accessor to a built \a T (for %printer).
|
||||
template <typename T>
|
||||
const T&
|
||||
as () const YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (yytypeid_);
|
||||
]b4_assert[ (*yytypeid_ == typeid (T));
|
||||
]b4_assert[ (sizeof (T) <= size);]])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
/// Swap the content with \a that, of same type.
|
||||
///
|
||||
/// Both variants must be built beforehand, because swapping the actual
|
||||
/// data requires reading it (with as()), and this is not possible on
|
||||
/// unconstructed variants: it would require some dynamic testing, which
|
||||
/// should not be the variant's responsibility.
|
||||
/// Swapping between built and (possibly) non-built is done with
|
||||
/// self_type::move ().
|
||||
template <typename T>
|
||||
void
|
||||
swap (self_type& that) YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (yytypeid_);
|
||||
]b4_assert[ (*yytypeid_ == *that.yytypeid_);]])[
|
||||
std::swap (as<T> (), that.as<T> ());
|
||||
}
|
||||
|
||||
/// Move the content of \a that to this.
|
||||
///
|
||||
/// Destroys \a that.
|
||||
template <typename T>
|
||||
void
|
||||
move (self_type& that)
|
||||
{
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
emplace<T> (std::move (that.as<T> ()));
|
||||
# else
|
||||
emplace<T> ();
|
||||
swap<T> (that);
|
||||
# endif
|
||||
that.destroy<T> ();
|
||||
}
|
||||
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
/// Move the content of \a that to this.
|
||||
template <typename T>
|
||||
void
|
||||
move (self_type&& that)
|
||||
{
|
||||
emplace<T> (std::move (that.as<T> ()));
|
||||
that.destroy<T> ();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Copy the content of \a that to this.
|
||||
template <typename T>
|
||||
void
|
||||
copy (const self_type& that)
|
||||
{
|
||||
emplace<T> (that.as<T> ());
|
||||
}
|
||||
|
||||
/// Destroy the stored \a T.
|
||||
template <typename T>
|
||||
void
|
||||
destroy ()
|
||||
{
|
||||
as<T> ().~T ();]b4_parse_assert_if([
|
||||
yytypeid_ = YY_NULLPTR;])[
|
||||
}
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
value_type (const self_type&);
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&);
|
||||
#endif
|
||||
|
||||
/// Accessor to raw memory as \a T.
|
||||
template <typename T>
|
||||
T*
|
||||
yyas_ () YY_NOEXCEPT
|
||||
{
|
||||
void *yyp = yyraw_;
|
||||
return static_cast<T*> (yyp);
|
||||
}
|
||||
|
||||
/// Const accessor to raw memory as \a T.
|
||||
template <typename T>
|
||||
const T*
|
||||
yyas_ () const YY_NOEXCEPT
|
||||
{
|
||||
const void *yyp = yyraw_;
|
||||
return static_cast<const T*> (yyp);
|
||||
}
|
||||
|
||||
/// An auxiliary type to compute the largest semantic type.
|
||||
union union_type
|
||||
{]b4_type_foreach([b4_char_sizeof])[ };
|
||||
|
||||
/// The size of the largest semantic type.
|
||||
enum { size = sizeof (union_type) };
|
||||
|
||||
/// A buffer to store semantic values.
|
||||
union
|
||||
{
|
||||
/// Strongest alignment constraints.
|
||||
long double yyalign_me_;
|
||||
/// A buffer large enough to store any of the semantic values.
|
||||
char yyraw_[size];
|
||||
};]b4_parse_assert_if([
|
||||
|
||||
/// Whether the content is built: if defined, the name of the stored type.
|
||||
const std::type_info *yytypeid_;])[
|
||||
};
|
||||
]])
|
||||
|
||||
|
||||
# How the semantic value is extracted when using variants.
|
||||
|
||||
# b4_symbol_value(VAL, SYMBOL-NUM, [TYPE])
|
||||
# ----------------------------------------
|
||||
# See README.
|
||||
m4_define([b4_symbol_value],
|
||||
[m4_ifval([$3],
|
||||
[$1.as< $3 > ()],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[$1.as < b4_symbol([$2], [type]) > ()],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
|
||||
# -------------------------------------------------
|
||||
# Same as b4_symbol_value, but used in a template method.
|
||||
m4_define([b4_symbol_value_template],
|
||||
[m4_ifval([$3],
|
||||
[$1.template as< $3 > ()],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[$1.template as < b4_symbol([$2], [type]) > ()],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## make_SYMBOL. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# _b4_includes_tokens(SYMBOL-NUM...)
|
||||
# ----------------------------------
|
||||
# Expands to non-empty iff one of the SYMBOL-NUM denotes
|
||||
# a token.
|
||||
m4_define([_b4_is_token],
|
||||
[b4_symbol_if([$1], [is_token], [1])])
|
||||
m4_define([_b4_includes_tokens],
|
||||
[m4_map([_b4_is_token], [$@])])
|
||||
|
||||
|
||||
# _b4_token_maker_define(SYMBOL-NUM)
|
||||
# ----------------------------------
|
||||
# Declare make_SYMBOL for SYMBOL-NUM. Use at class-level.
|
||||
m4_define([_b4_token_maker_define],
|
||||
[b4_token_visible_if([$1],
|
||||
[#if 201103L <= YY_CPLUSPLUS
|
||||
static
|
||||
symbol_type
|
||||
make_[]_b4_symbol([$1], [id]) (b4_join(
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[b4_symbol([$1], [type]) v]),
|
||||
b4_locations_if([location_type l])))
|
||||
{
|
||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||
b4_locations_if([std::move (l)])));
|
||||
}
|
||||
#else
|
||||
static
|
||||
symbol_type
|
||||
make_[]_b4_symbol([$1], [id]) (b4_join(
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l])))
|
||||
{
|
||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||
b4_symbol_if([$1], [has_type], [v]),
|
||||
b4_locations_if([l])));
|
||||
}
|
||||
#endif
|
||||
])])
|
||||
|
||||
|
||||
# b4_token_kind(SYMBOL-NUM)
|
||||
# -------------------------
|
||||
# Some tokens don't have an ID.
|
||||
m4_define([b4_token_kind],
|
||||
[b4_symbol_if([$1], [has_id],
|
||||
[token::b4_symbol([$1], [id])],
|
||||
[b4_symbol([$1], [code])])])
|
||||
|
||||
|
||||
# _b4_tok_in(SYMBOL-NUM, ...)
|
||||
# ---------------------------
|
||||
# See b4_tok_in below. The SYMBOL-NUMs... are tokens only.
|
||||
#
|
||||
# We iterate over the tokens to group them by "range" of token numbers (not
|
||||
# symbols numbers!).
|
||||
#
|
||||
# b4_fst is the start of that range.
|
||||
# b4_prev is the previous value.
|
||||
# b4_val is the current value.
|
||||
# If b4_val is the successor of b4_prev in token numbers, update the latter,
|
||||
# otherwise emit the code for range b4_fst .. b4_prev.
|
||||
# $1 is also used as a terminator in the foreach, but it will not be printed.
|
||||
#
|
||||
m4_define([_b4_tok_in],
|
||||
[m4_pushdef([b4_prev], [$1])dnl
|
||||
m4_pushdef([b4_fst], [$1])dnl
|
||||
m4_pushdef([b4_sep], [])dnl
|
||||
m4_foreach([b4_val], m4_dquote(m4_shift($@, $1)),
|
||||
[m4_if(b4_symbol(b4_val, [code]), m4_eval(b4_symbol(b4_prev, [code]) + 1), [],
|
||||
[b4_sep[]m4_if(b4_fst, b4_prev,
|
||||
[tok == b4_token_kind(b4_fst)],
|
||||
[(b4_token_kind(b4_fst) <= tok && tok <= b4_token_kind(b4_prev))])[]dnl
|
||||
m4_define([b4_fst], b4_val)dnl
|
||||
m4_define([b4_sep], [
|
||||
|| ])])dnl
|
||||
m4_define([b4_prev], b4_val)])dnl
|
||||
m4_popdef([b4_sep])dnl
|
||||
m4_popdef([b4_fst])dnl
|
||||
m4_popdef([b4_prev])dnl
|
||||
])
|
||||
|
||||
|
||||
# _b4_filter_tokens(SYMBOL-NUM, ...)
|
||||
# ----------------------------------
|
||||
# Expand as the list of tokens amongst SYMBOL-NUM.
|
||||
m4_define([_b4_filter_tokens],
|
||||
[m4_pushdef([b4_sep])dnl
|
||||
m4_foreach([b4_val], [$@],
|
||||
[b4_symbol_if(b4_val, [is_token], [b4_sep[]b4_val[]m4_define([b4_sep], [,])])])dnl
|
||||
m4_popdef([b4_sep])dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_tok_in(SYMBOL-NUM, ...)
|
||||
# ---------------------------
|
||||
# A C++ conditional that checks that `tok` is a member of this list of symbol
|
||||
# numbers.
|
||||
m4_define([b4_tok_in],
|
||||
[_$0(_b4_filter_tokens($@))])
|
||||
|
||||
|
||||
|
||||
|
||||
# _b4_symbol_constructor_define(SYMBOL-NUM...)
|
||||
# --------------------------------------------
|
||||
# Define a symbol_type constructor common to all the SYMBOL-NUM (they
|
||||
# have the same type). Use at class-level.
|
||||
m4_define([_b4_symbol_constructor_define],
|
||||
[m4_ifval(_b4_includes_tokens($@),
|
||||
[[#if 201103L <= YY_CPLUSPLUS
|
||||
symbol_type (]b4_join(
|
||||
[int tok],
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[b4_symbol([$1], [type]) v]),
|
||||
b4_locations_if([location_type l]))[)
|
||||
: super_type (]b4_join([token_kind_type (tok)],
|
||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||
b4_locations_if([std::move (l)]))[)
|
||||
#else
|
||||
symbol_type (]b4_join(
|
||||
[int tok],
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l]))[)
|
||||
: super_type (]b4_join([token_kind_type (tok)],
|
||||
b4_symbol_if([$1], [has_type], [v]),
|
||||
b4_locations_if([l]))[)
|
||||
#endif
|
||||
{]b4_parse_assert_if([[
|
||||
#if !defined _MSC_VER || defined __clang__
|
||||
]b4_assert[ (]b4_tok_in($@)[);
|
||||
#endif
|
||||
]])[}
|
||||
]])])
|
||||
|
||||
|
||||
# b4_basic_symbol_constructor_define(SYMBOL-NUM)
|
||||
# ----------------------------------------------
|
||||
# Generate a constructor for basic_symbol from given type.
|
||||
m4_define([b4_basic_symbol_constructor_define],
|
||||
[[#if 201103L <= YY_CPLUSPLUS
|
||||
basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
|
||||
b4_locations_if([location_type&& l]))[)
|
||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||
, value (std::move (v))])[]b4_locations_if([
|
||||
, location (std::move (l))])[
|
||||
{}
|
||||
#else
|
||||
basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l]))[)
|
||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||
, value (v)])[]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}
|
||||
#endif
|
||||
]])
|
||||
|
||||
|
||||
# b4_token_constructor_define
|
||||
# ---------------------------
|
||||
# Define the overloaded versions of make_FOO for all the token kinds.
|
||||
m4_define([b4_token_constructor_define],
|
||||
[ // Implementation of make_symbol for each token kind.
|
||||
b4_symbol_foreach([_b4_token_maker_define])])
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1 +1 @@
|
|||
4a6e1dced61dab2fcd828edbfbfa7eb0215cf2a4
|
||||
061b603bf44294decd88febdb111398610f92a87
|
|
@ -1 +1 @@
|
|||
bc50b3b6e84a30940aa1223f692c9f1fc9bedbf9
|
||||
0c624de29f012d318b2e2b055257704fd88077d5
|
|
@ -1 +1 @@
|
|||
06836e45b05d597d56b74febe3bcfd76e80ef8f8
|
||||
4e40328eccb622c73629e488c04460d008752d21
|
|
@ -1 +1 @@
|
|||
d0beab7ec77b25ac71bd2d3bf54f4efd39e3947f
|
||||
d3f9be12ad495666fd5df5375f18d4ed61debbdc
|
|
@ -1 +1 @@
|
|||
0579f1563e220d6121b65a5f4729919cd0cb6af9
|
||||
d57393e08051fab9edd79eb148fb184821fcde61
|
|
@ -1 +1 @@
|
|||
212a9ef90e21a98ff57ca301a60c84cbeca7be28
|
||||
828bf580e9db618cb93067a1bd90fcce6a9d869a
|
Загрузка…
Ссылка в новой задаче