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].
This commit is contained in:
David Young 2021-03-15 08:16:22 -05:00 committed by GitHub
parent 24c83cf73e
commit f6d919a2ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1913 additions and 1923 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,11 +18,15 @@
*/
%{
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <hdf5.h>
#include "H5private.h"
#include "H5LTparse.h"
static char *trim_quotes(const char *);
int my_yyinput(char *, int);
#undef YY_INPUT
#define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms))
@ -37,43 +41,8 @@ int my_yyinput(char *, int);
extern char *myinput;
extern size_t input_len;
#define STACK_SIZE 16
/*variables for compound type*/
struct cmpd_info {
hid_t id;
hbool_t is_field;
hbool_t first_memb;
};
extern struct cmpd_info cmpd_stack[STACK_SIZE];
extern int csindex;
/*variables for array type*/
struct arr_info {
hsize_t dims[H5S_MAX_RANK];
int ndim;
hbool_t is_dim;
};
extern struct arr_info arr_stack[STACK_SIZE];
extern int asindex;
/*variables for enumerate type*/
extern hbool_t is_enum;
extern hbool_t is_enum_memb;
/*variables for string type*/
extern hbool_t is_str_size;
/*variables for opaque type*/
extern hbool_t is_opq_size;
extern hbool_t is_opq_tag;
hbool_t first_quote = 1;
%}
%s TAG_STRING
%%
H5T_STD_I8BE {return hid(H5T_STD_I8BE_TOKEN);}
@ -138,32 +107,12 @@ OPQ_SIZE {return token(OPQ_SIZE_TOKEN);}
OPQ_TAG {return token(OPQ_TAG_TOKEN);}
[0-9]+ {
if( is_str_size || (is_enum && is_enum_memb) ||
is_opq_size || (asindex>-1 && arr_stack[asindex].is_dim) ||
(csindex>-1 && cmpd_stack[csindex].is_field) ) {
H5LTyylval.ival = atoi(yytext);
return NUMBER;
} else
REJECT;
H5LTyylval.ival = HDatoi(yytext);
return NUMBER;
}
"\"" {
/*if it's first quote, and is a compound field name or an enum symbol*/
if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field))
&& first_quote) {
first_quote = 0;
BEGIN TAG_STRING;
} else /*if it's second quote*/
first_quote = 1;
return token('"');
}
<TAG_STRING>[^\"]+ {
#ifdef H5_HAVE_WIN32_API
H5LTyylval.sval = _strdup(yytext);
#else /* H5_HAVE_WIN32_API */
H5LTyylval.sval = strdup(yytext);
#endif /* H5_HAVE_WIN32_API */
BEGIN INITIAL;
["][^\"]+["] {
H5LTyylval.sval = trim_quotes(yytext);
return STRING;
}
@ -177,18 +126,37 @@ OPQ_TAG {return token(OPQ_TAG_TOKEN);}
"\n" { return 0; }
%%
/* Allocate a copy of `quoted` with the double quote character at
* the beginning and the one at the end both removed. The caller is
* responsible for free()ing the copy.
*/
static char *
trim_quotes(const char *quoted)
{
size_t len = HDstrlen(quoted);
char *trimmed;
HDassert(quoted[0] == '"' && quoted[len - 1] == '"');
trimmed = HDstrdup(quoted + 1);
trimmed[len - 2] = '\0';
return trimmed;
}
int my_yyinput(char *buf, int max_size)
{
int ret;
memcpy(buf, myinput, input_len);
HDmemcpy(buf, myinput, input_len);
ret = (int)input_len;
return ret;
}
int H5LTyyerror(const char *msg)
{
printf("ERROR: %s before \"%s\".\n", msg, yytext);
HDprintf("ERROR: %s before \"%s\".\n", msg, yytext);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -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 */

View File

@ -22,7 +22,9 @@
#include <string.h>
#include <hdf5.h>
extern int yylex();
#include "H5private.h"
extern int yylex(void);
extern int yyerror(const char *);
#define STACK_SIZE 16
@ -35,13 +37,13 @@ struct cmpd_info {
};
/*stack for nested compound type*/
struct cmpd_info cmpd_stack[STACK_SIZE] = {
static struct cmpd_info cmpd_stack[STACK_SIZE] = {
{0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1},
{0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1},
{0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1},
{0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1} };
int csindex = -1; /*pointer to the top of compound stack*/
static int csindex = -1; /*pointer to the top of compound stack*/
/*structure for array type information*/
struct arr_info {
@ -50,23 +52,18 @@ struct arr_info {
hbool_t is_dim; /*flag to lexer for dimension*/
};
/*stack for nested array type*/
struct arr_info arr_stack[STACK_SIZE];
int asindex = -1; /*pointer to the top of array stack*/
static struct arr_info arr_stack[STACK_SIZE];
static int asindex = -1; /*pointer to the top of array stack*/
hbool_t is_str_size = 0; /*flag to lexer for string size*/
hbool_t is_str_pad = 0; /*flag to lexer for string padding*/
H5T_str_t str_pad; /*variable for string padding*/
H5T_cset_t str_cset; /*variable for string character set*/
hbool_t is_variable = 0; /*variable for variable-length string*/
size_t str_size; /*variable for string size*/
static H5T_str_t str_pad; /*variable for string padding*/
static H5T_cset_t str_cset; /*variable for string character set*/
static hbool_t is_variable = 0; /*variable for variable-length string*/
static size_t str_size; /*variable for string size*/
hid_t enum_id; /*type ID*/
hbool_t is_enum = 0; /*flag to lexer for enum type*/
hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/
char* enum_memb_symbol; /*enum member symbol string*/
hbool_t is_opq_size = 0; /*flag to lexer for opaque type size*/
hbool_t is_opq_tag = 0; /*flag to lexer for opaque type tag*/
static hid_t enum_id; /*type ID*/
static hbool_t is_enum = 0; /*flag to lexer for enum type*/
static hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/
static char* enum_memb_symbol; /*enum member symbol string*/
%}
%union {
@ -99,7 +96,7 @@ hbool_t is_opq_tag = 0; /*flag to lexer for opaque type tag*/
%token <sval> STRING
%token <ival> NUMBER
%token <ival> '{' '}' '[' ']' '"' ':' ';'
%token <ival> '{' '}' '[' ']' ':' ';'
%%
start : { memset(arr_stack, 0, STACK_SIZE*sizeof(struct arr_info)); /*initialize here?*/ }
@ -168,35 +165,35 @@ memb_list :
| memb_list memb_def
;
memb_def : ddl_type { cmpd_stack[csindex].is_field = 1; /*notify lexer a compound member is parsed*/ }
'"' field_name '"' field_offset ';'
field_name field_offset ';'
{
size_t origin_size, new_size;
hid_t dtype_id = cmpd_stack[csindex].id;
/*Adjust size and insert member, consider both member size and offset.*/
if(cmpd_stack[csindex].first_memb) { /*reclaim the size 1 temporarily set*/
new_size = H5Tget_size($<hid>1) + $<ival>6;
new_size = H5Tget_size($<hid>1) + $<ival>4;
H5Tset_size(dtype_id, new_size);
/*member name is saved in yylval.sval by lexer*/
H5Tinsert(dtype_id, $<sval>4, $<ival>6, $<hid>1);
H5Tinsert(dtype_id, $<sval>3, $<ival>4, $<hid>1);
cmpd_stack[csindex].first_memb = 0;
} else {
origin_size = H5Tget_size(dtype_id);
if($<ival>6 == 0) {
if($<ival>4 == 0) {
new_size = origin_size + H5Tget_size($<hid>1);
H5Tset_size(dtype_id, new_size);
H5Tinsert(dtype_id, $<sval>4, origin_size, $<hid>1);
H5Tinsert(dtype_id, $<sval>3, origin_size, $<hid>1);
} else {
new_size = $<ival>6 + H5Tget_size($<hid>1);
new_size = $<ival>4 + H5Tget_size($<hid>1);
H5Tset_size(dtype_id, new_size);
H5Tinsert(dtype_id, $<sval>4, $<ival>6, $<hid>1);
H5Tinsert(dtype_id, $<sval>3, $<ival>4, $<hid>1);
}
}
if($<sval>4) {
free($<sval>4);
$<sval>4 = NULL;
if($<sval>3) {
HDfree($<sval>3);
$<sval>3 = NULL;
}
cmpd_stack[csindex].is_field = 0;
H5Tclose($<hid>1);
@ -206,8 +203,8 @@ memb_def : ddl_type { cmpd_stack[csindex].is_field = 1; /*notify le
;
field_name : STRING
{
$<sval>$ = strdup(yylval.sval);
free(yylval.sval);
$<sval>$ = HDstrdup(yylval.sval);
HDfree(yylval.sval);
yylval.sval = NULL;
}
;
@ -247,20 +244,18 @@ vlen_type : H5T_VLEN_TOKEN '{' ddl_type '}'
opaque_type : H5T_OPAQUE_TOKEN
'{'
OPQ_SIZE_TOKEN { is_opq_size = 1; } opaque_size ';'
OPQ_SIZE_TOKEN opaque_size ';'
{
size_t size = (size_t)yylval.ival;
$<hid>$ = H5Tcreate(H5T_OPAQUE, size);
is_opq_size = 0;
}
OPQ_TAG_TOKEN { is_opq_tag = 1; } '"' opaque_tag '"' ';'
OPQ_TAG_TOKEN opaque_tag ';'
{
H5Tset_tag($<hid>7, yylval.sval);
free(yylval.sval);
H5Tset_tag($<hid>6, yylval.sval);
HDfree(yylval.sval);
yylval.sval = NULL;
is_opq_tag = 0;
}
'}' { $<hid>$ = $<hid>7; }
'}' { $<hid>$ = $<hid>6; }
;
opaque_size : NUMBER
;
@ -268,40 +263,39 @@ opaque_tag : STRING
;
string_type : H5T_STRING_TOKEN
'{'
STRSIZE_TOKEN { is_str_size = 1; } strsize ';'
STRSIZE_TOKEN strsize ';'
{
if($<ival>5 == H5T_VARIABLE_TOKEN)
if($<ival>4 == H5T_VARIABLE_TOKEN)
is_variable = 1;
else
str_size = yylval.ival;
is_str_size = 0;
}
STRPAD_TOKEN strpad ';'
{
if($<ival>9 == H5T_STR_NULLTERM_TOKEN)
if($<ival>8 == H5T_STR_NULLTERM_TOKEN)
str_pad = H5T_STR_NULLTERM;
else if($<ival>9 == H5T_STR_NULLPAD_TOKEN)
else if($<ival>8 == H5T_STR_NULLPAD_TOKEN)
str_pad = H5T_STR_NULLPAD;
else if($<ival>9 == H5T_STR_SPACEPAD_TOKEN)
else if($<ival>8 == H5T_STR_SPACEPAD_TOKEN)
str_pad = H5T_STR_SPACEPAD;
}
CSET_TOKEN cset ';'
{
if($<ival>13 == H5T_CSET_ASCII_TOKEN)
if($<ival>12 == H5T_CSET_ASCII_TOKEN)
str_cset = H5T_CSET_ASCII;
else if($<ival>13 == H5T_CSET_UTF8_TOKEN)
else if($<ival>12 == H5T_CSET_UTF8_TOKEN)
str_cset = H5T_CSET_UTF8;
}
CTYPE_TOKEN ctype ';'
{
if($<hid>17 == H5T_C_S1_TOKEN)
if($<hid>16 == H5T_C_S1_TOKEN)
$<hid>$ = H5Tcopy(H5T_C_S1);
else if($<hid>17 == H5T_FORTRAN_S1_TOKEN)
else if($<hid>16 == H5T_FORTRAN_S1_TOKEN)
$<hid>$ = H5Tcopy(H5T_FORTRAN_S1);
}
'}'
{
hid_t str_id = $<hid>19;
hid_t str_id = $<hid>18;
/*set string size*/
if(is_variable) {
@ -339,14 +333,10 @@ enum_type : H5T_ENUM_TOKEN '{' integer_type ';'
enum_list :
| enum_list enum_def
;
enum_def : '"' enum_symbol '"' {
enum_def : enum_symbol {
is_enum_memb = 1; /*indicate member of enum*/
#ifdef H5_HAVE_WIN32_API
enum_memb_symbol = _strdup(yylval.sval);
#else /* H5_HAVE_WIN32_API */
enum_memb_symbol = strdup(yylval.sval);
#endif /* H5_HAVE_WIN32_API */
free(yylval.sval);
HDfree(yylval.sval);
yylval.sval = NULL;
}
enum_val ';'
@ -386,7 +376,7 @@ enum_def : '"' enum_symbol '"' {
}
is_enum_memb = 0;
if(enum_memb_symbol) free(enum_memb_symbol);
if(enum_memb_symbol) HDfree(enum_memb_symbol);
}
H5Tclose(super);