diff options
author | David Young <dyoung@hdfgroup.org> | 2021-03-15 13:16:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-15 13:16:22 (GMT) |
commit | f6d919a2ab0034a1ee76ca2d5f59f4d8114c4952 (patch) | |
tree | 1850a385e92e3e434c9723fba3de1e870d5703b7 /hl/src/H5LTparse.h | |
parent | 24c83cf73ebb80a58ce92463dac02713d3a4dbf8 (diff) | |
download | hdf5-f6d919a2ab0034a1ee76ca2d5f59f4d8114c4952.zip hdf5-f6d919a2ab0034a1ee76ca2d5f59f4d8114c4952.tar.gz hdf5-f6d919a2ab0034a1ee76ca2d5f59f4d8114c4952.tar.bz2 |
Simplified hl parsing (#399)
* Stop using global variables to share parse context with the lexer.
The lexer uses an unconventional strategy for parsing lexical categories
NUMBER (decimal numbers) and STRING (double-quoted strings) that involves
sharing the parse context with the lexer using global variables. There
are a couple of problems with that. First, the lexer is too complicated
for the simple tokenization it performs—it's hard to tell if it is
correct. Second, as @seanm points out, the shared global variables
spill into the namespace shared by other libraries and application
programs—e.g., VTK.
* Regenerate source files from *.[yl].
* Replace strndup, which isn't available on Windows, with a custom
routine, `trim_quotes`, that produces a copy of its `const char *`
argument with leading and trailing double quotes ('"') removed.
While I am here, remove the unnecessary statement `BEGIN INITIAL;`,
which I should have deleted in a previous commit.
* Regenerate .c from .l.
* You haven't programmed in C until you have programmed in High-Definition
(HD) C.
* \#include "H5private.h" for HD* definitions.
* Regenerate *.[ch] from *.[yl].
Diffstat (limited to 'hl/src/H5LTparse.h')
-rw-r--r-- | hl/src/H5LTparse.h | 174 |
1 files changed, 89 insertions, 85 deletions
diff --git a/hl/src/H5LTparse.h b/hl/src/H5LTparse.h index abff969..7169017 100644 --- a/hl/src/H5LTparse.h +++ b/hl/src/H5LTparse.h @@ -1,20 +1,19 @@ -/* A Bison parser, made by GNU Bison 3.7.2. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, - Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2012 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 <http://www.gnu.org/licenses/>. */ @@ -27,17 +26,13 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -/* 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_H5LTYY_HL_SRC_H5LTPARSE_H_INCLUDED # define YY_H5LTYY_HL_SRC_H5LTPARSE_H_INCLUDED -/* Debug traces. */ +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif @@ -45,96 +40,105 @@ extern int H5LTyydebug; #endif -/* Token kinds. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - enum yytokentype - { - YYEMPTY = -2, - YYEOF = 0, /* "end of file" */ - YYerror = 256, /* error */ - YYUNDEF = 257, /* "invalid token" */ - H5T_STD_I8BE_TOKEN = 258, /* H5T_STD_I8BE_TOKEN */ - H5T_STD_I8LE_TOKEN = 259, /* H5T_STD_I8LE_TOKEN */ - H5T_STD_I16BE_TOKEN = 260, /* H5T_STD_I16BE_TOKEN */ - H5T_STD_I16LE_TOKEN = 261, /* H5T_STD_I16LE_TOKEN */ - H5T_STD_I32BE_TOKEN = 262, /* H5T_STD_I32BE_TOKEN */ - H5T_STD_I32LE_TOKEN = 263, /* H5T_STD_I32LE_TOKEN */ - H5T_STD_I64BE_TOKEN = 264, /* H5T_STD_I64BE_TOKEN */ - H5T_STD_I64LE_TOKEN = 265, /* H5T_STD_I64LE_TOKEN */ - H5T_STD_U8BE_TOKEN = 266, /* H5T_STD_U8BE_TOKEN */ - H5T_STD_U8LE_TOKEN = 267, /* H5T_STD_U8LE_TOKEN */ - H5T_STD_U16BE_TOKEN = 268, /* H5T_STD_U16BE_TOKEN */ - H5T_STD_U16LE_TOKEN = 269, /* H5T_STD_U16LE_TOKEN */ - H5T_STD_U32BE_TOKEN = 270, /* H5T_STD_U32BE_TOKEN */ - H5T_STD_U32LE_TOKEN = 271, /* H5T_STD_U32LE_TOKEN */ - H5T_STD_U64BE_TOKEN = 272, /* H5T_STD_U64BE_TOKEN */ - H5T_STD_U64LE_TOKEN = 273, /* H5T_STD_U64LE_TOKEN */ - H5T_NATIVE_CHAR_TOKEN = 274, /* H5T_NATIVE_CHAR_TOKEN */ - H5T_NATIVE_SCHAR_TOKEN = 275, /* H5T_NATIVE_SCHAR_TOKEN */ - H5T_NATIVE_UCHAR_TOKEN = 276, /* H5T_NATIVE_UCHAR_TOKEN */ - H5T_NATIVE_SHORT_TOKEN = 277, /* H5T_NATIVE_SHORT_TOKEN */ - H5T_NATIVE_USHORT_TOKEN = 278, /* H5T_NATIVE_USHORT_TOKEN */ - H5T_NATIVE_INT_TOKEN = 279, /* H5T_NATIVE_INT_TOKEN */ - H5T_NATIVE_UINT_TOKEN = 280, /* H5T_NATIVE_UINT_TOKEN */ - H5T_NATIVE_LONG_TOKEN = 281, /* H5T_NATIVE_LONG_TOKEN */ - H5T_NATIVE_ULONG_TOKEN = 282, /* H5T_NATIVE_ULONG_TOKEN */ - H5T_NATIVE_LLONG_TOKEN = 283, /* H5T_NATIVE_LLONG_TOKEN */ - H5T_NATIVE_ULLONG_TOKEN = 284, /* H5T_NATIVE_ULLONG_TOKEN */ - H5T_IEEE_F32BE_TOKEN = 285, /* H5T_IEEE_F32BE_TOKEN */ - H5T_IEEE_F32LE_TOKEN = 286, /* H5T_IEEE_F32LE_TOKEN */ - H5T_IEEE_F64BE_TOKEN = 287, /* H5T_IEEE_F64BE_TOKEN */ - H5T_IEEE_F64LE_TOKEN = 288, /* H5T_IEEE_F64LE_TOKEN */ - H5T_NATIVE_FLOAT_TOKEN = 289, /* H5T_NATIVE_FLOAT_TOKEN */ - H5T_NATIVE_DOUBLE_TOKEN = 290, /* H5T_NATIVE_DOUBLE_TOKEN */ - H5T_NATIVE_LDOUBLE_TOKEN = 291, /* H5T_NATIVE_LDOUBLE_TOKEN */ - H5T_STRING_TOKEN = 292, /* H5T_STRING_TOKEN */ - STRSIZE_TOKEN = 293, /* STRSIZE_TOKEN */ - STRPAD_TOKEN = 294, /* STRPAD_TOKEN */ - CSET_TOKEN = 295, /* CSET_TOKEN */ - CTYPE_TOKEN = 296, /* CTYPE_TOKEN */ - H5T_VARIABLE_TOKEN = 297, /* H5T_VARIABLE_TOKEN */ - H5T_STR_NULLTERM_TOKEN = 298, /* H5T_STR_NULLTERM_TOKEN */ - H5T_STR_NULLPAD_TOKEN = 299, /* H5T_STR_NULLPAD_TOKEN */ - H5T_STR_SPACEPAD_TOKEN = 300, /* H5T_STR_SPACEPAD_TOKEN */ - H5T_CSET_ASCII_TOKEN = 301, /* H5T_CSET_ASCII_TOKEN */ - H5T_CSET_UTF8_TOKEN = 302, /* H5T_CSET_UTF8_TOKEN */ - H5T_C_S1_TOKEN = 303, /* H5T_C_S1_TOKEN */ - H5T_FORTRAN_S1_TOKEN = 304, /* H5T_FORTRAN_S1_TOKEN */ - H5T_OPAQUE_TOKEN = 305, /* H5T_OPAQUE_TOKEN */ - OPQ_SIZE_TOKEN = 306, /* OPQ_SIZE_TOKEN */ - OPQ_TAG_TOKEN = 307, /* OPQ_TAG_TOKEN */ - H5T_COMPOUND_TOKEN = 308, /* H5T_COMPOUND_TOKEN */ - H5T_ENUM_TOKEN = 309, /* H5T_ENUM_TOKEN */ - H5T_ARRAY_TOKEN = 310, /* H5T_ARRAY_TOKEN */ - H5T_VLEN_TOKEN = 311, /* H5T_VLEN_TOKEN */ - STRING = 312, /* STRING */ - NUMBER = 313 /* NUMBER */ - }; - typedef enum yytokentype yytoken_kind_t; + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + H5T_STD_I8BE_TOKEN = 258, + H5T_STD_I8LE_TOKEN = 259, + H5T_STD_I16BE_TOKEN = 260, + H5T_STD_I16LE_TOKEN = 261, + H5T_STD_I32BE_TOKEN = 262, + H5T_STD_I32LE_TOKEN = 263, + H5T_STD_I64BE_TOKEN = 264, + H5T_STD_I64LE_TOKEN = 265, + H5T_STD_U8BE_TOKEN = 266, + H5T_STD_U8LE_TOKEN = 267, + H5T_STD_U16BE_TOKEN = 268, + H5T_STD_U16LE_TOKEN = 269, + H5T_STD_U32BE_TOKEN = 270, + H5T_STD_U32LE_TOKEN = 271, + H5T_STD_U64BE_TOKEN = 272, + H5T_STD_U64LE_TOKEN = 273, + H5T_NATIVE_CHAR_TOKEN = 274, + H5T_NATIVE_SCHAR_TOKEN = 275, + H5T_NATIVE_UCHAR_TOKEN = 276, + H5T_NATIVE_SHORT_TOKEN = 277, + H5T_NATIVE_USHORT_TOKEN = 278, + H5T_NATIVE_INT_TOKEN = 279, + H5T_NATIVE_UINT_TOKEN = 280, + H5T_NATIVE_LONG_TOKEN = 281, + H5T_NATIVE_ULONG_TOKEN = 282, + H5T_NATIVE_LLONG_TOKEN = 283, + H5T_NATIVE_ULLONG_TOKEN = 284, + H5T_IEEE_F32BE_TOKEN = 285, + H5T_IEEE_F32LE_TOKEN = 286, + H5T_IEEE_F64BE_TOKEN = 287, + H5T_IEEE_F64LE_TOKEN = 288, + H5T_NATIVE_FLOAT_TOKEN = 289, + H5T_NATIVE_DOUBLE_TOKEN = 290, + H5T_NATIVE_LDOUBLE_TOKEN = 291, + H5T_STRING_TOKEN = 292, + STRSIZE_TOKEN = 293, + STRPAD_TOKEN = 294, + CSET_TOKEN = 295, + CTYPE_TOKEN = 296, + H5T_VARIABLE_TOKEN = 297, + H5T_STR_NULLTERM_TOKEN = 298, + H5T_STR_NULLPAD_TOKEN = 299, + H5T_STR_SPACEPAD_TOKEN = 300, + H5T_CSET_ASCII_TOKEN = 301, + H5T_CSET_UTF8_TOKEN = 302, + H5T_C_S1_TOKEN = 303, + H5T_FORTRAN_S1_TOKEN = 304, + H5T_OPAQUE_TOKEN = 305, + OPQ_SIZE_TOKEN = 306, + OPQ_TAG_TOKEN = 307, + H5T_COMPOUND_TOKEN = 308, + H5T_ENUM_TOKEN = 309, + H5T_ARRAY_TOKEN = 310, + H5T_VLEN_TOKEN = 311, + STRING = 312, + NUMBER = 313 + }; #endif -/* Value type. */ + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -union YYSTYPE +typedef union YYSTYPE { -#line 72 "hl/src/H5LTparse.y" +/* Line 2058 of yacc.c */ +#line 69 "hl/src//H5LTparse.y" int ival; /*for integer token*/ char *sval; /*for name string*/ hid_t hid; /*for hid_t token*/ -#line 128 "hl/src/H5LTparse.h" -}; -typedef union YYSTYPE YYSTYPE; +/* Line 2058 of yacc.c */ +#line 122 "hl/src//H5LTparse.h" +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif - extern YYSTYPE H5LTyylval; +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +hid_t H5LTyyparse (void *YYPARSE_PARAM); +#else +hid_t H5LTyyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus hid_t H5LTyyparse (void); +#else +hid_t H5LTyyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ #endif /* !YY_H5LTYY_HL_SRC_H5LTPARSE_H_INCLUDED */ |