From e42d7d7f61ad47cf55fa3a53875ea80adcb27a9d Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Sat, 5 May 2012 22:31:24 +0000 Subject: [PATCH] fix bug in opaque parsing --- cf | 3 +- libsrc4/nc4file.c | 14 +- nc_test4/tst_dims3.c | 6 +- ncgen/cvt.c | 1 + ncgen/ncgen.l | 3 +- ncgen/ncgen.y | 12 +- ncgen/ncgentab.c | 935 ++++++++++++----------- ncgen/ncgenyy.c | 1720 ++++++++++++++++++------------------------ 8 files changed, 1247 insertions(+), 1447 deletions(-) diff --git a/cf b/cf index c712684e7..0a7670419 100644 --- a/cf +++ b/cf @@ -125,7 +125,8 @@ FLAGS="$FLAGS --disable-pnetcdf" #FLAGS="$FLAGS --enable-dap-long-tests" #FLAGS="$FLAGS --enable-ffio" #FLAGS="$FLAGS --enable-benchmarks" -#FLAGS="$FLAGS --enable-extra-tests" +FLAGS="$FLAGS --enable-extra-tests" +FLAGS="$FLAGS --enable-logging" #FLAGS="$FLAGS --enable-large-file-tests" #FLAGS="$FLAGS --disable-testsets" #FLAGS="$FLAGS --enable-mmap" diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 2b4c7764b..bea85d842 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -2967,19 +2967,21 @@ close_netcdf4_file(NC_HDF5_FILE_INFO_T *h5, int abort) { if (H5Fclose(h5->hdfid) < 0) { + int nobjs; + nobjs = H5Fget_obj_count(h5->hdfid, H5F_OBJ_ALL); + /* Apparently we can get an error even when nobjs == 0 */ + if(nobjs < 0) { + return NC_EHDFERR; + } else if(nobjs > 0) { #ifdef LOGGING /* If the close doesn't work, probably there are still some HDF5 * objects open, which means there's a bug in the library. So * print out some info on to help the poor programmer figure it * out. */ - { - int nobjs; - if ((nobjs = H5Fget_obj_count(h5->hdfid, H5F_OBJ_ALL) < 0)) - return NC_EHDFERR; - LOG((0, "There are %d HDF5 objects open!", nobjs)); - } + LOG((0, "There are %d HDF5 objects open!", nobjs)); #endif return NC_EHDFERR; + } } /* if (H5garbage_collect() < 0) return NC_EHDFERR; */ diff --git a/nc_test4/tst_dims3.c b/nc_test4/tst_dims3.c index a731307c9..f165014cf 100644 --- a/nc_test4/tst_dims3.c +++ b/nc_test4/tst_dims3.c @@ -13,6 +13,7 @@ int main(int argc, char **argv) { +nc_set_log_level(0); printf("\n*** Testing netcdf-4 dimensions even more.\n"); printf("*** testing netcdf-4 dimension inheritance..."); { @@ -78,7 +79,7 @@ main(int argc, char **argv) SUMMARIZE_ERR; printf("*** testing a scalar coordinate dimension..."); { - int ncid, dimid, varid; + int ncid, dimid, varid, stat; float data = 42.5; /* Create a scalar coordinate dimension. The only reason that @@ -92,7 +93,8 @@ main(int argc, char **argv) if (nc_def_dim(ncid, "scalar", 0, &dimid)) ERR_RET; if (nc_def_var(ncid, "scalar", NC_FLOAT, 0, &dimid, &varid)) ERR_RET; if (nc_put_var_float(ncid, varid, &data)) ERR_RET; - if (nc_close(ncid)) ERR_RET; + if (nc_close(ncid)) + ERR_RET; } SUMMARIZE_ERR; FINAL_RESULTS; diff --git a/ncgen/cvt.c b/ncgen/cvt.c index 70a6fd0c8..52aeb3447 100644 --- a/ncgen/cvt.c +++ b/ncgen/cvt.c @@ -526,6 +526,7 @@ case CASE(NC_OPAQUE,NC_OPAQUE): tmp.opaquev.stringv = (char*)malloc(src->value.opaquev.len); memcpy(tmp.opaquev.stringv,src->value.opaquev.stringv,src->value.opaquev.len); tmp.opaquev.len = src->value.opaquev.len; + tmp.opaquev.stringv[tmp.opaquev.len] = '\0'; break; /* We are missing all CASE(X,NC_ECONST) cases*/ diff --git a/ncgen/ncgen.l b/ncgen/ncgen.l index cc666f58f..830dd18e2 100644 --- a/ncgen/ncgen.l +++ b/ncgen/ncgen.l @@ -190,10 +190,9 @@ yytext[MAXTRST-1] = '\0'; {OPAQUESTRING} { /* drop leading 0x; pad to even number of chars */ char* p = yytext+2; int len = yyleng - 2; - int padlen = len; - if((padlen % 2) == 1) padlen++; bbClear(lextext); bbAppendn(lextext,p,len); + if((len % 2) == 1) bbAppend(lextext,'0'); bbNull(lextext); /* convert all chars to lower case */ for(p=bbContents(lextext);*p;p++) *p = tolower(*p); diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index 0a06975d3..c96a3f46b 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -1033,17 +1033,13 @@ makeconstdata(nc_type nctype) #ifdef USE_NETCDF4 case NC_OPAQUE: { char* s; - int len,padlen; + int len; len = bbLength(lextext); - padlen = len; - if(padlen < 16) padlen = 16; - if((padlen % 2) == 1) padlen++; - s = (char*)emalloc(padlen+1); - memset((void*)s,'0',padlen); - s[padlen]='\0'; + s = (char*)emalloc(len+1); strncpy(s,bbContents(lextext),len); + s[len] = '\0'; con.value.opaquev.stringv = s; - con.value.opaquev.len = padlen; + con.value.opaquev.len = len; } break; #endif diff --git a/ncgen/ncgentab.c b/ncgen/ncgentab.c index af0df8c54..86f1ea202 100644 --- a/ncgen/ncgentab.c +++ b/ncgen/ncgentab.c @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ +/* A Bison parser, made by GNU Bison 2.5. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2011 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 @@ -45,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.3" +#define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -74,7 +73,7 @@ /* Copy the first part of user declarations. */ -/* Line 189 of yacc.c */ +/* Line 268 of yacc.c */ #line 11 "ncgen.y" /* @@ -194,8 +193,8 @@ extern int lex_init(void); -/* Line 189 of yacc.c */ -#line 199 "ncgen.tab.c" +/* Line 268 of yacc.c */ +#line 198 "ncgen.tab.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -278,7 +277,7 @@ extern int lex_init(void); typedef union YYSTYPE { -/* Line 214 of yacc.c */ +/* Line 293 of yacc.c */ #line 131 "ncgen.y" Symbol* sym; @@ -290,8 +289,8 @@ Constant constant; -/* Line 214 of yacc.c */ -#line 295 "ncgen.tab.c" +/* Line 293 of yacc.c */ +#line 294 "ncgen.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -302,8 +301,8 @@ Constant constant; /* Copy the second part of user declarations. */ -/* Line 264 of yacc.c */ -#line 307 "ncgen.tab.c" +/* Line 343 of yacc.c */ +#line 306 "ncgen.tab.c" #ifdef short # undef short @@ -406,11 +405,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -433,24 +432,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -479,23 +478,7 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of @@ -515,6 +498,26 @@ union yyalloc #endif +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + /* YYFINAL -- State number of the termination state. */ #define YYFINAL 4 /* YYLAST -- Last index in YYTABLE. */ @@ -749,8 +752,8 @@ static const yytype_uint8 yyr2[] = 1, 1, 1, 1, 1, 1, 1, 1 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { @@ -839,8 +842,7 @@ static const yytype_int16 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ + number is the opposite. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -104 static const yytype_int16 yytable[] = { @@ -884,6 +886,12 @@ static const yytype_int16 yytable[] = 78, 79, 80 }; +#define yypact_value_is_default(yystate) \ + ((yystate) == (-127)) + +#define yytable_value_is_error(yytable_value) \ + YYID (0) + static const yytype_int16 yycheck[] = { 36, 20, 128, 23, 34, 15, 114, 38, 83, 98, @@ -990,7 +998,6 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -1032,19 +1039,10 @@ while (YYID (0)) #endif -/* YY_LOCATION_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. */ +/* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif @@ -1236,7 +1234,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -1339,115 +1336,142 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) { - int yyn = yypact[yystate]; + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = 0; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -1480,6 +1504,7 @@ yydestruct (yymsg, yytype, yyvaluep) } } + /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus @@ -1506,10 +1531,9 @@ YYSTYPE yylval; int yynerrs; - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ +/*----------. +| yyparse. | +`----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1533,8 +1557,6 @@ yyparse () #endif #endif { - - int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -1689,7 +1711,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1720,8 +1742,8 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -1776,14 +1798,14 @@ yyreduce: { case 2: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 210 "ncgen.y" - {if (error_count > 0) YYABORT;;} + {if (error_count > 0) YYABORT;} break; case 7: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 230 "ncgen.y" { Symbol* id = (yyvsp[(2) - (3)].sym); @@ -1791,33 +1813,33 @@ yyreduce: if(creategroup(id) == NULL) yyerror("duplicate group declaration within parent group for %s", id->name); - ;} + } break; case 8: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 239 "ncgen.y" - {listpop(groupstack);;} + {listpop(groupstack);} break; case 11: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 245 "ncgen.y" - {;} + {} break; case 12: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 247 "ncgen.y" - {markcdf4("Type specification");;} + {markcdf4("Type specification");} break; case 15: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 253 "ncgen.y" { /* Use when defining a type */ (yyvsp[(1) - (1)].sym)->objectclass = NC_TYPE; @@ -1825,26 +1847,26 @@ yyreduce: yyerror("duplicate type declaration for %s", (yyvsp[(1) - (1)].sym)->name); listpush(typdefs,(elem_t)(yyvsp[(1) - (1)].sym)); - ;} + } break; case 16: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 262 "ncgen.y" - {;} + {} break; case 17: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 262 "ncgen.y" - {;} + {} break; case 24: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 276 "ncgen.y" { int i; @@ -1871,19 +1893,19 @@ yyreduce: eid->typ.basetype = (yyvsp[(3) - (6)].sym)->typ.basetype; } listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } break; case 25: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 305 "ncgen.y" - {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));;} + {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));} break; case 26: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 307 "ncgen.y" { int i; @@ -1898,24 +1920,24 @@ yyreduce: elem->name); } listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym)); - ;} + } break; case 27: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 324 "ncgen.y" { (yyvsp[(1) - (3)].sym)->objectclass=NC_TYPE; (yyvsp[(1) - (3)].sym)->subclass=NC_ECONST; (yyvsp[(1) - (3)].sym)->typ.econst=(yyvsp[(3) - (3)].constant); (yyval.sym)=(yyvsp[(1) - (3)].sym); - ;} + } break; case 28: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 333 "ncgen.y" { vercheck(NC_OPAQUE); @@ -1925,12 +1947,12 @@ yyreduce: (yyvsp[(5) - (5)].sym)->typ.typecode=NC_OPAQUE; (yyvsp[(5) - (5)].sym)->typ.size=int32_val; (yyvsp[(5) - (5)].sym)->typ.alignment=nctypealignment(NC_OPAQUE); - ;} + } break; case 29: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 345 "ncgen.y" { Symbol* basetype = (yyvsp[(1) - (5)].sym); @@ -1942,12 +1964,12 @@ yyreduce: (yyvsp[(5) - (5)].sym)->typ.typecode=NC_VLEN; (yyvsp[(5) - (5)].sym)->typ.size=VLENSIZE; (yyvsp[(5) - (5)].sym)->typ.alignment=nctypealignment(NC_VLEN); - ;} + } break; case 30: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 359 "ncgen.y" { int i,j; @@ -1977,26 +1999,26 @@ yyreduce: listpush((yyvsp[(2) - (5)].sym)->subnodes,(elem_t)fsym); } listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } break; case 31: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 391 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (2)].mark);;} + {(yyval.mark)=(yyvsp[(1) - (2)].mark);} break; case 32: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 392 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark);;} + {(yyval.mark)=(yyvsp[(1) - (3)].mark);} break; case 33: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 396 "ncgen.y" { int i; @@ -2008,129 +2030,129 @@ yyreduce: Symbol* f = (Symbol*)listget(stack,i); f->typ.basetype = (yyvsp[(1) - (2)].sym); } - ;} + } break; case 34: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 409 "ncgen.y" - { (yyval.sym) = primsymbols[NC_CHAR]; ;} + { (yyval.sym) = primsymbols[NC_CHAR]; } break; case 35: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 410 "ncgen.y" - { (yyval.sym) = primsymbols[NC_BYTE]; ;} + { (yyval.sym) = primsymbols[NC_BYTE]; } break; case 36: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 411 "ncgen.y" - { (yyval.sym) = primsymbols[NC_SHORT]; ;} + { (yyval.sym) = primsymbols[NC_SHORT]; } break; case 37: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 412 "ncgen.y" - { (yyval.sym) = primsymbols[NC_INT]; ;} + { (yyval.sym) = primsymbols[NC_INT]; } break; case 38: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 413 "ncgen.y" - { (yyval.sym) = primsymbols[NC_FLOAT]; ;} + { (yyval.sym) = primsymbols[NC_FLOAT]; } break; case 39: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 414 "ncgen.y" - { (yyval.sym) = primsymbols[NC_DOUBLE]; ;} + { (yyval.sym) = primsymbols[NC_DOUBLE]; } break; case 40: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 415 "ncgen.y" - { vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; ;} + { vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; } break; case 41: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 416 "ncgen.y" - { vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; ;} + { vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; } break; case 42: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 417 "ncgen.y" - { vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; ;} + { vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; } break; case 43: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 418 "ncgen.y" - { vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; ;} + { vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; } break; case 44: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 419 "ncgen.y" - { vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; ;} + { vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; } break; case 46: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 423 "ncgen.y" - {;} + {} break; case 47: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 424 "ncgen.y" - {;} + {} break; case 50: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 431 "ncgen.y" - {;} + {} break; case 51: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 431 "ncgen.y" - {;} + {} break; case 54: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 439 "ncgen.y" { (yyvsp[(1) - (3)].sym)->dim.declsize = (size_t)uint32_val; #ifdef DEBUG1 fprintf(stderr,"dimension: %s = %lu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned long)(yyvsp[(1) - (3)].sym)->dim.declsize); #endif - ;} + } break; case 55: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 446 "ncgen.y" { if(int32_val <= 0) { @@ -2141,12 +2163,12 @@ fprintf(stderr,"dimension: %s = %lu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned lo #ifdef DEBUG1 fprintf(stderr,"dimension: %s = %lu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned long)(yyvsp[(1) - (3)].sym)->dim.declsize); #endif - ;} + } break; case 56: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 457 "ncgen.y" { /* for rare case where 2^31 < dimsize < 2^32 */ if (double_val <= 0) @@ -2159,12 +2181,12 @@ fprintf(stderr,"dimension: %s = %lu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned lo #ifdef DEBUG1 fprintf(stderr,"dimension: %s = %lu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned long)(yyvsp[(1) - (3)].sym)->dim.declsize); #endif - ;} + } break; case 57: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 470 "ncgen.y" { (yyvsp[(1) - (3)].sym)->dim.declsize = NC_UNLIMITED; @@ -2172,12 +2194,12 @@ fprintf(stderr,"dimension: %s = %lu\n",(yyvsp[(1) - (3)].sym)->name,(unsigned lo #ifdef DEBUG1 fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); #endif - ;} + } break; case 58: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 480 "ncgen.y" { (yyvsp[(1) - (1)].sym)->objectclass=NC_DIM; @@ -2187,40 +2209,40 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); addtogroup((yyvsp[(1) - (1)].sym)); (yyval.sym)=(yyvsp[(1) - (1)].sym); listpush(dimdefs,(elem_t)(yyvsp[(1) - (1)].sym)); - ;} + } break; case 60: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 492 "ncgen.y" - {;} + {} break; case 61: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 493 "ncgen.y" - {;} + {} break; case 64: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 500 "ncgen.y" - {;} + {} break; case 65: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 500 "ncgen.y" - {;} + {} break; case 66: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 503 "ncgen.y" { int i; @@ -2240,28 +2262,28 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); } } listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } break; case 67: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 525 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym)); - ;} + } break; case 68: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 529 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));} break; case 69: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 533 "ncgen.y" { int i; @@ -2286,40 +2308,40 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); (yyvsp[(1) - (2)].sym)->typ.basetype = NULL; /* not yet known*/ (yyvsp[(1) - (2)].sym)->objectclass=NC_VAR; listsetlength(stack,stackbase);/* remove stack nodes*/ - ;} + } break; case 70: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 559 "ncgen.y" - {(yyval.mark)=listlength(stack);;} + {(yyval.mark)=listlength(stack);} break; case 71: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 560 "ncgen.y" - {(yyval.mark)=(yyvsp[(2) - (3)].mark);;} + {(yyval.mark)=(yyvsp[(2) - (3)].mark);} break; case 72: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 563 "ncgen.y" - {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));;} + {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));} break; case 73: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 565 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));} break; case 74: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 569 "ncgen.y" {Symbol* dimsym = (yyvsp[(1) - (1)].sym); dimsym->objectclass = NC_DIM; @@ -2330,28 +2352,28 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); YYABORT; } (yyval.sym)=dimsym; - ;} + } break; case 75: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 583 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym)); - ;} + } break; case 76: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 587 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));} break; case 77: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 592 "ncgen.y" { int i; @@ -2378,40 +2400,40 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); (yyvsp[(1) - (2)].sym)->subclass=NC_FIELD; listsetlength(stack,stackbase);/* remove stack nodes*/ (yyval.sym) = (yyvsp[(1) - (2)].sym); - ;} + } break; case 78: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 620 "ncgen.y" - {(yyval.mark)=listlength(stack);;} + {(yyval.mark)=listlength(stack);} break; case 79: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 621 "ncgen.y" - {(yyval.mark)=(yyvsp[(2) - (3)].mark);;} + {(yyval.mark)=(yyvsp[(2) - (3)].mark);} break; case 80: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 625 "ncgen.y" - {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));;} + {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));} break; case 81: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 627 "ncgen.y" - {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} + {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));} break; case 82: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 632 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ @@ -2421,12 +2443,12 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); (yyval.sym)->objectclass = NC_DIM; (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = uint32_val; - ;} + } break; case 83: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 642 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ @@ -2440,12 +2462,12 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); (yyval.sym)->objectclass = NC_DIM; (yyval.sym)->dim.isconstant = 1; (yyval.sym)->dim.declsize = int32_val; - ;} + } break; case 84: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 662 "ncgen.y" {Symbol* vsym = (yyvsp[(1) - (1)].sym); if(vsym->objectclass != NC_VAR) { @@ -2453,12 +2475,12 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); YYABORT; } (yyval.sym)=vsym; - ;} + } break; case 85: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 673 "ncgen.y" {Symbol* tsym = (yyvsp[(1) - (1)].sym); if(tsym->objectclass != NC_TYPE) { @@ -2466,12 +2488,12 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); YYABORT; } (yyval.sym)=tsym; - ;} + } break; case 86: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 684 "ncgen.y" {Symbol* tvsym = (yyvsp[(1) - (1)].sym); Symbol* sym; /* disambiguate*/ @@ -2490,40 +2512,40 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); YYABORT; } (yyval.sym)=tvsym; - ;} + } break; case 87: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 702 "ncgen.y" - {(yyval.sym)=(yyvsp[(1) - (1)].sym);;} + {(yyval.sym)=(yyvsp[(1) - (1)].sym);} break; case 88: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 709 "ncgen.y" - {;} + {} break; case 89: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 709 "ncgen.y" - {;} + {} break; case 90: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 713 "ncgen.y" - { (yyval.sym)=makeattribute((yyvsp[(2) - (4)].sym),NULL,NULL,(yyvsp[(4) - (4)].datalist),ATTRGLOBAL);;} + { (yyval.sym)=makeattribute((yyvsp[(2) - (4)].sym),NULL,NULL,(yyvsp[(4) - (4)].datalist),ATTRGLOBAL);} break; case 91: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 715 "ncgen.y" {Symbol* tsym = (yyvsp[(1) - (6)].sym); Symbol* vsym = (yyvsp[(2) - (6)].sym); Symbol* asym = (yyvsp[(4) - (6)].sym); if(vsym->objectclass == NC_VAR) { @@ -2532,12 +2554,12 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); derror("Doubly typed attribute: %s",asym->name); YYABORT; } - ;} + } break; case 92: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 724 "ncgen.y" {Symbol* sym = (yyvsp[(1) - (5)].sym); Symbol* asym = (yyvsp[(3) - (5)].sym); if(sym->objectclass == NC_VAR) { @@ -2548,381 +2570,392 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); derror("Attribute prefix not a variable or type: %s",asym->name); YYABORT; } - ;} + } break; case 93: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 735 "ncgen.y" - {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);;} + {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);} break; case 94: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 737 "ncgen.y" - {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(2) - (6)].sym),(yyvsp[(1) - (6)].sym),(void*)(yyvsp[(6) - (6)].datalist),0);;} + {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(2) - (6)].sym),(yyvsp[(1) - (6)].sym),(void*)(yyvsp[(6) - (6)].datalist),0);} break; case 95: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 739 "ncgen.y" - {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} + {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 96: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 741 "ncgen.y" - {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);;} + {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);} break; case 97: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 743 "ncgen.y" - {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} + {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 98: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 745 "ncgen.y" - {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} + {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 99: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 747 "ncgen.y" - {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} + {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 100: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 749 "ncgen.y" - {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} + {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 101: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 751 "ncgen.y" - {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} + {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);} break; case 102: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 753 "ncgen.y" - {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),1);;} + {(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),1);} break; case 103: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 758 "ncgen.y" { (yyval.sym)=(yyvsp[(1) - (1)].sym); (yyvsp[(1) - (1)].sym)->is_ref=1; setpathcurrent((yyvsp[(1) - (1)].sym)); - ;} + } break; case 104: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 764 "ncgen.y" { (yyval.sym)=(yyvsp[(1) - (1)].sym); (yyvsp[(1) - (1)].sym)->is_ref=1; (yyvsp[(1) - (1)].sym)->is_prefixed=1; /* path is set in ncgen.l*/ - ;} + } break; case 106: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 773 "ncgen.y" - {;} + {} break; case 107: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 774 "ncgen.y" - {;} + {} break; case 110: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 782 "ncgen.y" - {(yyvsp[(1) - (3)].sym)->data = (yyvsp[(3) - (3)].datalist);;} + {(yyvsp[(1) - (3)].sym)->data = (yyvsp[(3) - (3)].datalist);} break; case 111: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 785 "ncgen.y" - {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);;} + {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);} break; case 112: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 786 "ncgen.y" - {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);;} + {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);} break; case 113: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 790 "ncgen.y" - {(yyval.datalist) = builddatalist(0);;} + {(yyval.datalist) = builddatalist(0);} break; case 114: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 794 "ncgen.y" - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));} break; case 115: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 796 "ncgen.y" - {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);;} + {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);} break; case 116: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 800 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 117: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 801 "ncgen.y" - {(yyval.constant)=builddatasublist((yyvsp[(2) - (3)].datalist));;} + {(yyval.constant)=builddatasublist((yyvsp[(2) - (3)].datalist));} break; case 118: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 805 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 119: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 806 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_OPAQUE);;} + {(yyval.constant)=makeconstdata(NC_OPAQUE);} break; case 120: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 807 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_FILLVALUE);;} + {(yyval.constant)=makeconstdata(NC_FILLVALUE);} break; case 121: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 808 "ncgen.y" - {(yyval.constant)=makeenumconst((yyvsp[(1) - (1)].sym));;} + {(yyval.constant)=makeenumconst((yyvsp[(1) - (1)].sym));} break; case 123: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 813 "ncgen.y" - {(yyval.constant)=evaluate((yyvsp[(1) - (4)].sym),(yyvsp[(3) - (4)].datalist));;} + {(yyval.constant)=evaluate((yyvsp[(1) - (4)].sym),(yyvsp[(3) - (4)].datalist));} break; case 124: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 818 "ncgen.y" - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));} break; case 125: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 820 "ncgen.y" - {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);;} + {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);} break; case 126: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 824 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_CHAR);;} + {(yyval.constant)=makeconstdata(NC_CHAR);} break; case 127: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 825 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_BYTE);;} + {(yyval.constant)=makeconstdata(NC_BYTE);} break; case 128: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 826 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_SHORT);;} + {(yyval.constant)=makeconstdata(NC_SHORT);} break; case 129: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 827 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT);;} + {(yyval.constant)=makeconstdata(NC_INT);} break; case 130: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 828 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT64);;} + {(yyval.constant)=makeconstdata(NC_INT64);} break; case 131: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 829 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UBYTE);;} + {(yyval.constant)=makeconstdata(NC_UBYTE);} break; case 132: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 830 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_USHORT);;} + {(yyval.constant)=makeconstdata(NC_USHORT);} break; case 133: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 831 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT);;} + {(yyval.constant)=makeconstdata(NC_UINT);} break; case 134: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 832 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT64);;} + {(yyval.constant)=makeconstdata(NC_UINT64);} break; case 135: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 833 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_FLOAT);;} + {(yyval.constant)=makeconstdata(NC_FLOAT);} break; case 136: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 834 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_DOUBLE);;} + {(yyval.constant)=makeconstdata(NC_DOUBLE);} break; case 137: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 835 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_STRING);;} + {(yyval.constant)=makeconstdata(NC_STRING);} break; case 138: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 839 "ncgen.y" - {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} + {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));} break; case 139: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 840 "ncgen.y" - {(yyval.datalist)=(yyvsp[(1) - (3)].datalist); datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant)));;} + {(yyval.datalist)=(yyvsp[(1) - (3)].datalist); datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant)));} break; case 140: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 845 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT);;} + {(yyval.constant)=makeconstdata(NC_INT);} break; case 141: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 847 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT);;} + {(yyval.constant)=makeconstdata(NC_UINT);} break; case 142: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 849 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_INT64);;} + {(yyval.constant)=makeconstdata(NC_INT64);} break; case 143: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 851 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_UINT64);;} + {(yyval.constant)=makeconstdata(NC_UINT64);} break; case 144: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 855 "ncgen.y" - {(yyval.constant)=makeconstdata(NC_STRING);;} + {(yyval.constant)=makeconstdata(NC_STRING);} break; case 145: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 859 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 146: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 860 "ncgen.y" - {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} + {(yyval.constant)=(yyvsp[(1) - (1)].constant);} break; case 147: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 866 "ncgen.y" - {(yyval.sym)=(yyvsp[(1) - (1)].sym);;} + {(yyval.sym)=(yyvsp[(1) - (1)].sym);} break; -/* Line 1464 of yacc.c */ -#line 2924 "ncgen.tab.c" +/* Line 1806 of yacc.c */ +#line 2946 "ncgen.tab.c" default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -2950,6 +2983,10 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name); | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -2957,37 +2994,36 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } +# undef YYSYNTAX_ERROR #endif } @@ -3046,7 +3082,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -3105,8 +3141,13 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -3131,7 +3172,7 @@ yyreturn: -/* Line 1684 of yacc.c */ +/* Line 2067 of yacc.c */ #line 869 "ncgen.y" @@ -3300,17 +3341,13 @@ makeconstdata(nc_type nctype) #ifdef USE_NETCDF4 case NC_OPAQUE: { char* s; - int len,padlen; + int len; len = bbLength(lextext); - padlen = len; - if(padlen < 16) padlen = 16; - if((padlen % 2) == 1) padlen++; - s = (char*)emalloc(padlen+1); - memset((void*)s,'0',padlen); - s[padlen]='\0'; + s = (char*)emalloc(len+1); strncpy(s,bbContents(lextext),len); + s[len] = '\0'; con.value.opaquev.stringv = s; - con.value.opaquev.len = padlen; + con.value.opaquev.len = len; } break; #endif diff --git a/ncgen/ncgenyy.c b/ncgen/ncgenyy.c index 7827a0be7..738a1a513 100644 --- a/ncgen/ncgenyy.c +++ b/ncgen/ncgenyy.c @@ -1,12 +1,8 @@ - -#line 3 "lex.ncg.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - #define yy_create_buffer ncg_create_buffer #define yy_delete_buffer ncg_delete_buffer +#define yy_scan_buffer ncg_scan_buffer +#define yy_scan_string ncg_scan_string +#define yy_scan_bytes ncg_scan_bytes #define yy_flex_debug ncg_flex_debug #define yy_init_buffer ncg_init_buffer #define yy_flush_buffer ncg_flush_buffer @@ -15,117 +11,75 @@ #define yyin ncgin #define yyleng ncgleng #define yylex ncglex -#define yylineno ncglineno #define yyout ncgout #define yyrestart ncgrestart #define yytext ncgtext #define yywrap ncgwrap -#define yyalloc ncgalloc -#define yyrealloc ncgrealloc -#define yyfree ncgfree + +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ #include -#include -#include -#include -/* end standard C headers. */ -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif #endif -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ #ifdef __cplusplus +#include +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) +#if __STDC__ +#define YY_USE_PROTOS #define YY_USE_CONST -#endif /* defined (__STDC__) */ +#endif /* __STDC__ */ #endif /* ! __cplusplus */ +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + /* Returned upon end-of-file. */ #define YY_NULL 0 @@ -140,70 +94,71 @@ typedef unsigned int flex_uint32_t; * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ -#define BEGIN (yy_start) = 1 + 2 * +#define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START (((yy_start) - 1) / 2) +#define YY_START ((yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE ncgrestart(ncgin ) +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ -#ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 -#endif -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif -extern int ncgleng; - -extern FILE *ncgin, *ncgout; +extern int yyleng; +extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + #define yyless(n) \ do \ { \ - /* Undo effects of setting up ncgtext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up ncgtext again */ \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) -#define unput(c) yyunput( c, (yytext_ptr) ) +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; @@ -240,16 +195,12 @@ struct yy_buffer_state */ int yy_at_bol; - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; - #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process @@ -259,135 +210,99 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via ncgrestart()), so that the user can continue scanning by - * just pointing ncgin at a new input file. + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE yy_current_buffer = 0; /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". - * - * Returns the top of the stack, or NULL. */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) +#define YY_CURRENT_BUFFER yy_current_buffer -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] -/* yy_hold_char holds the character lost when ncgtext is formed. */ +/* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; + static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int ncgleng; + + +int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ +static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ -/* Flag which is used to allow ncgwrap()'s to do buffer switches - * instead of setting up a fresh ncgin. A bit of a hack ... +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; -void ncgrestart (FILE *input_file ); -void ncg_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE ncg_create_buffer (FILE *file,int size ); -void ncg_delete_buffer (YY_BUFFER_STATE b ); -void ncg_flush_buffer (YY_BUFFER_STATE b ); -void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer ); -void ncgpop_buffer_state (void ); +void yyrestart YY_PROTO(( FILE *input_file )); -static void ncgensure_buffer_stack (void ); -static void ncg_load_buffer_state (void ); -static void ncg_init_buffer (YY_BUFFER_STATE b,FILE *file ); +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) -#define YY_FLUSH_BUFFER ncg_flush_buffer(YY_CURRENT_BUFFER ) +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); -YY_BUFFER_STATE ncg_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE ncg_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,int len ); +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); -void *ncgalloc (yy_size_t ); -void *ncgrealloc (void *,yy_size_t ); -void ncgfree (void * ); - -#define yy_new_buffer ncg_create_buffer +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ - if ( ! YY_CURRENT_BUFFER ){ \ - ncgensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - ncg_create_buffer(ncgin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ - if ( ! YY_CURRENT_BUFFER ){\ - ncgensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - ncg_create_buffer(ncgin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) typedef unsigned char YY_CHAR; - -FILE *ncgin = (FILE *) 0, *ncgout = (FILE *) 0; - +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext -extern int ncglineno; - -int ncglineno = 1; - -extern char *ncgtext; -#define yytext_ptr ncgtext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); /* Done after the current pattern has been matched and before the - * corresponding action - sets up ncgtext. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - ncgleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; + yy_c_buf_p = yy_cp; #define YY_NUM_RULES 49 #define YY_END_OF_BUFFER 50 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[447] = +static yyconst short int yy_accept[447] = { 0, 0, 0, 46, 46, 0, 0, 50, 48, 1, 44, 48, 48, 48, 48, 38, 30, 34, 34, 33, 33, @@ -440,7 +355,7 @@ static yyconst flex_int16_t yy_accept[447] = 33, 22, 33, 21, 33, 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static yyconst int yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, @@ -472,7 +387,7 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[75] = +static yyconst int yy_meta[75] = { 0, 1, 1, 2, 1, 1, 1, 3, 4, 5, 5, 5, 6, 7, 7, 7, 7, 7, 7, 7, 1, @@ -484,7 +399,7 @@ static yyconst flex_int32_t yy_meta[75] = 1, 9, 9, 9 } ; -static yyconst flex_int16_t yy_base[464] = +static yyconst short int yy_base[464] = { 0, 0, 0, 330, 329, 266, 264, 331, 2548, 73, 2548, 70, 284, 67, 81, 120, 108, 172, 285, 56, 68, @@ -539,7 +454,7 @@ static yyconst flex_int16_t yy_base[464] = 2525, 2533, 2537 } ; -static yyconst flex_int16_t yy_def[464] = +static yyconst short int yy_def[464] = { 0, 446, 1, 447, 447, 448, 448, 446, 446, 446, 446, 449, 450, 446, 446, 446, 451, 446, 17, 452, 452, @@ -594,7 +509,7 @@ static yyconst flex_int16_t yy_def[464] = 446, 446, 446 } ; -static yyconst flex_int16_t yy_nxt[2623] = +static yyconst short int yy_nxt[2623] = { 0, 8, 9, 10, 9, 8, 11, 12, 8, 13, 14, 15, 16, 17, 18, 18, 18, 18, 18, 18, 8, @@ -887,7 +802,7 @@ static yyconst flex_int16_t yy_nxt[2623] = 446, 446 } ; -static yyconst flex_int16_t yy_chk[2623] = +static yyconst short int yy_chk[2623] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1183,9 +1098,6 @@ static yyconst flex_int16_t yy_chk[2623] = static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; -extern int ncg_flex_debug; -int ncg_flex_debug = 0; - /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -1193,8 +1105,9 @@ int ncg_flex_debug = 0; #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *ncgtext; +char *yytext; #line 1 "ncgen.l" +#define INITIAL 0 #line 2 "ncgen.l" /********************************************************************* * Copyright 1993, UCAR/Unidata @@ -1278,7 +1191,9 @@ static struct Specialtoken { {NULL,0} /* null terminate */ }; +#define ST_C_COMMENT 1 +#define TEXT 2 /* The most correct (validating) version of UTF8 character set (Taken from: http://www.w3.org/2005/03/23-lex-U) @@ -1321,54 +1236,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})* /* Note: this definition of string will work for utf8 as well, although it is a very relaxed definition */ -#line 1325 "lex.ncg.c" - -#define INITIAL 0 -#define ST_C_COMMENT 1 -#define TEXT 2 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int ncglex_destroy (void ); - -int ncgget_debug (void ); - -void ncgset_debug (int debug_flag ); - -YY_EXTRA_TYPE ncgget_extra (void ); - -void ncgset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *ncgget_in (void ); - -void ncgset_in (FILE * in_str ); - -FILE *ncgget_out (void ); - -void ncgset_out (FILE * out_str ); - -int ncgget_leng (void ); - -char *ncgget_text (void ); - -int ncgget_lineno (void ); - -void ncgset_lineno (int line_number ); +#line 1240 "lex.ncg.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1376,30 +1244,65 @@ void ncgset_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int ncgwrap (void ); +extern "C" int yywrap YY_PROTO(( void )); #else -extern int ncgwrap (void ); +extern int yywrap YY_PROTO(( void )); #endif #endif - static void yyunput (int c,char *buf_ptr ); - +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen YY_PROTO(( yyconst char * )); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput YY_PROTO(( void )); #else -static int input (void ); +static int input YY_PROTO(( void )); +#endif #endif +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif #endif /* Amount of stuff to slurp up with each read. */ @@ -1408,11 +1311,12 @@ static int input (void ); #endif /* Copy whatever the last rule matched to the standard output. */ + #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( ncgtext, ncgleng, 1, ncgout )) {} } while (0) +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1420,35 +1324,21 @@ static int input (void ); */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + if ( yy_current_buffer->yy_is_interactive ) \ { \ - int c = '*'; \ - unsigned n; \ + int c = '*', n; \ for ( n = 0; n < max_size && \ - (c = getc( ncgin )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( ncgin ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, ncgin))==0 && ferror(ncgin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(ncgin); \ - } \ - }\ -\ - + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - @@ -1469,20 +1359,14 @@ static int input (void ); #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif -/* end tables serialization structures and prototypes */ - /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL -#define YY_DECL_IS_OURS 1 +#define YY_DECL int yylex YY_PROTO(( void )) +#endif -extern int ncglex (void); - -#define YY_DECL int ncglex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after ncgtext and ncgleng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -1497,65 +1381,61 @@ extern int ncglex (void); #define YY_RULE_SETUP \ YY_USER_ACTION -/** The main scanner function which does all the work. - */ YY_DECL -{ + { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; - + #line 165 "ncgen.l" -#line 1511 "lex.ncg.c" +#line 1393 "lex.ncg.c" - if ( !(yy_init) ) + if ( yy_init ) { - (yy_init) = 1; + yy_init = 0; #ifdef YY_USER_INIT YY_USER_INIT; #endif - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ + if ( ! yy_start ) + yy_start = 1; /* first start state */ - if ( ! ncgin ) - ncgin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! ncgout ) - ncgout = stdout; + if ( ! yyout ) + yyout = stdout; - if ( ! YY_CURRENT_BUFFER ) { - ncgensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - ncg_create_buffer(ncgin,YY_BUF_SIZE ); - } + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); - ncg_load_buffer_state( ); + yy_load_buffer_state(); } while ( 1 ) /* loops until end-of-file is reached */ { - yy_cp = (yy_c_buf_p); + yy_cp = yy_c_buf_p; - /* Support of ncgtext. */ - *yy_cp = (yy_hold_char); + /* Support of yytext. */ + *yy_cp = yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; - yy_current_state = (yy_start); + yy_current_state = yy_start; yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1572,22 +1452,24 @@ yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; + do_action: /* This label is used only to access EOF actions. */ + switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; goto yy_find_action; case 1: @@ -1605,21 +1487,20 @@ YY_RULE_SETUP } YY_BREAK case 3: -/* rule 3 can match eol */ YY_RULE_SETUP #line 174 "ncgen.l" { /* In netcdf4, this will be used in a variety of places, so only remove escapes */ /* -if(ncgleng > MAXTRST) { +if(yyleng > MAXTRST) { yyerror("string too long, truncated\n"); -ncgtext[MAXTRST-1] = '\0'; +yytext[MAXTRST-1] = '\0'; } */ /* Assumes expand escapes also does normalization */ bbClear(lextext); - expand_escapes(lextext,(char *)ncgtext,ncgleng); + expand_escapes(lextext,(char *)yytext,yyleng); bbNull(lextext); return lexdebug(TERMSTRING); } @@ -1628,12 +1509,11 @@ case 4: YY_RULE_SETUP #line 190 "ncgen.l" { /* drop leading 0x; pad to even number of chars */ - char* p = ncgtext+2; - int len = ncgleng - 2; - int padlen = len; - if((padlen % 2) == 1) padlen++; + char* p = yytext+2; + int len = yyleng - 2; bbClear(lextext); bbAppendn(lextext,p,len); + if((len % 2) == 1) bbAppend(lextext,'0'); bbNull(lextext); /* convert all chars to lower case */ for(p=bbContents(lextext);*p;p++) *p = tolower(*p); @@ -1642,115 +1522,115 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 203 "ncgen.l" +#line 202 "ncgen.l" {return lexdebug(COMPOUND);} YY_BREAK case 6: YY_RULE_SETUP -#line 204 "ncgen.l" +#line 203 "ncgen.l" {return lexdebug(ENUM);} YY_BREAK case 7: YY_RULE_SETUP -#line 205 "ncgen.l" +#line 204 "ncgen.l" {return lexdebug(OPAQUE);} YY_BREAK case 8: YY_RULE_SETUP -#line 207 "ncgen.l" +#line 206 "ncgen.l" {return lexdebug(FLOAT_K);} YY_BREAK case 9: YY_RULE_SETUP -#line 208 "ncgen.l" +#line 207 "ncgen.l" {return lexdebug(CHAR_K);} YY_BREAK case 10: YY_RULE_SETUP -#line 209 "ncgen.l" +#line 208 "ncgen.l" {return lexdebug(BYTE_K);} YY_BREAK case 11: YY_RULE_SETUP -#line 210 "ncgen.l" +#line 209 "ncgen.l" {return lexdebug(UBYTE_K);} YY_BREAK case 12: YY_RULE_SETUP -#line 211 "ncgen.l" +#line 210 "ncgen.l" {return lexdebug(SHORT_K);} YY_BREAK case 13: YY_RULE_SETUP -#line 212 "ncgen.l" +#line 211 "ncgen.l" {return lexdebug(USHORT_K);} YY_BREAK case 14: YY_RULE_SETUP -#line 213 "ncgen.l" +#line 212 "ncgen.l" {return lexdebug(INT_K);} YY_BREAK case 15: YY_RULE_SETUP -#line 214 "ncgen.l" +#line 213 "ncgen.l" {return lexdebug(UINT_K);} YY_BREAK case 16: YY_RULE_SETUP -#line 215 "ncgen.l" +#line 214 "ncgen.l" {return lexdebug(INT64_K);} YY_BREAK case 17: YY_RULE_SETUP -#line 216 "ncgen.l" +#line 215 "ncgen.l" {return lexdebug(UINT64_K);} YY_BREAK case 18: YY_RULE_SETUP -#line 217 "ncgen.l" +#line 216 "ncgen.l" {return lexdebug(DOUBLE_K);} YY_BREAK case 19: YY_RULE_SETUP -#line 218 "ncgen.l" +#line 217 "ncgen.l" {int32_val = -1; return lexdebug(NC_UNLIMITED_K);} YY_BREAK case 20: YY_RULE_SETUP -#line 221 "ncgen.l" +#line 220 "ncgen.l" {return lexdebug(TYPES);} YY_BREAK case 21: YY_RULE_SETUP -#line 222 "ncgen.l" +#line 221 "ncgen.l" {return lexdebug(DIMENSIONS);} YY_BREAK case 22: YY_RULE_SETUP -#line 223 "ncgen.l" +#line 222 "ncgen.l" {return lexdebug(VARIABLES);} YY_BREAK case 23: YY_RULE_SETUP -#line 224 "ncgen.l" +#line 223 "ncgen.l" {return lexdebug(DATA);} YY_BREAK case 24: YY_RULE_SETUP -#line 225 "ncgen.l" +#line 224 "ncgen.l" {return lexdebug(GROUP);} YY_BREAK case 25: YY_RULE_SETUP -#line 227 "ncgen.l" +#line 226 "ncgen.l" {BEGIN(TEXT);return lexdebug(NETCDF);} YY_BREAK case 26: YY_RULE_SETUP -#line 229 "ncgen.l" +#line 228 "ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ - if (ncgtext[0] == '-') { + if (yytext[0] == '-') { double_val = NEGINFINITE; } else { double_val = INFINITE; @@ -1761,7 +1641,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 238 "ncgen.l" +#line 237 "ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ double_val = NAN; specialconstants = 1; @@ -1770,9 +1650,9 @@ YY_RULE_SETUP YY_BREAK case 28: YY_RULE_SETUP -#line 244 "ncgen.l" +#line 243 "ncgen.l" {/* missing value (pre-2.4 backward compatibility)*/ - if (ncgtext[0] == '-') { + if (yytext[0] == '-') { float_val = NEGINFINITEF; } else { float_val = INFINITEF; @@ -1783,7 +1663,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 253 "ncgen.l" +#line 252 "ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ float_val = NANF; specialconstants = 1; @@ -1792,10 +1672,10 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 259 "ncgen.l" +#line 258 "ncgen.l" { bbClear(lextext); - bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ bbNull(lextext); yylval.sym = makepath(bbContents(lextext)); return lexdebug(PATH); @@ -1803,10 +1683,10 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 268 "ncgen.l" +#line 267 "ncgen.l" {struct Specialtoken* st; bbClear(lextext); - bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ bbNull(lextext); for(st=specials;st->name;st++) { if(strcmp(bbContents(lextext),st->name)==0) {return lexdebug(st->token);} @@ -1815,15 +1695,14 @@ YY_RULE_SETUP } YY_BREAK case 32: -/* rule 32 can match eol */ YY_RULE_SETUP -#line 278 "ncgen.l" +#line 277 "ncgen.l" { int c; char* p; char* q; /* copy the trimmed name */ bbClear(lextext); - bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ bbNull(lextext); p = bbContents(lextext); q = p; @@ -1836,10 +1715,10 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 294 "ncgen.l" +#line 293 "ncgen.l" { char* id; bbClear(lextext); - bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ bbNull(lextext); id = bbContents(lextext); deescapify(id); @@ -1850,12 +1729,12 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 305 "ncgen.l" +#line 304 "ncgen.l" { /* We need to try to see what size of integer ((u)int). */ /* Technically, the user should specify, but... */ /* If out of any integer range, then complain */ - switch (parseLL(ncgtext)) { + switch (parseLL(yytext)) { case 0: return lexdebug(INT64_CONST); /* meaningless */ case -1: @@ -1870,7 +1749,7 @@ YY_RULE_SETUP if(int64_val >=NC_MIN_INT) { int32_val = (int)int64_val; } else { - sprintf(errstr,"32 bit integer constant out of range: %s",(char*)ncgtext); + sprintf(errstr,"32 bit integer constant out of range: %s",(char*)yytext); yyerror(errstr); } return lexdebug(INT_CONST); @@ -1891,7 +1770,7 @@ YY_RULE_SETUP #else /* Convert to int32 but complain if overflow */ if(uint64_val > NC_MAX_INT) { - sprintf(errstr,"32 bit integer constant out of range: %s",(char*)ncgtext); + sprintf(errstr,"32 bit integer constant out of range: %s",(char*)yytext); yyerror(errstr); } int32_val = (int)uint64_val; @@ -1902,15 +1781,15 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 354 "ncgen.l" +#line 353 "ncgen.l" { /* The number may be signed or unsigned (signed has priority) */ - int slen = strlen(ncgtext); - int tag = ncgtext[slen-1]; + int slen = strlen(yytext); + int tag = yytext[slen-1]; int token = 0; switch (tag) { case 'B': case 'b': - if (sscanf((char*)ncgtext, "%d", &int32_val) != 1) { - sprintf(errstr,"bad byte constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%d", &int32_val) != 1) { + sprintf(errstr,"bad byte constant: %s",(char*)yytext); yyerror(errstr); } else if(int32_val >= NC_MIN_BYTE && int32_val <= NC_MAX_BYTE) { byte_val = (signed char)int32_val; @@ -1919,13 +1798,13 @@ YY_RULE_SETUP ubyte_val = (unsigned char)int32_val; token = UBYTE_CONST; } else { - sprintf(errstr,"bad byte constant: %s",(char*)ncgtext); + sprintf(errstr,"bad byte constant: %s",(char*)yytext); yyerror(errstr); } break; case 'S': case 's': - if (sscanf((char*)ncgtext, "%d", &int32_val) != 1) { - sprintf(errstr,"bad short constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%d", &int32_val) != 1) { + sprintf(errstr,"bad short constant: %s",(char*)yytext); yyerror(errstr); } else if(int32_val >= NC_MIN_SHORT && int32_val <= NC_MAX_SHORT) { int16_val = (signed short)int32_val; @@ -1934,14 +1813,14 @@ YY_RULE_SETUP uint16_val = (unsigned short)int32_val; token = USHORT_CONST; } else { - sprintf(errstr,"bad short constant: %s",(char*)ncgtext); + sprintf(errstr,"bad short constant: %s",(char*)yytext); yyerror(errstr); } break; case 'L': case 'l': - switch(parseLL(ncgtext)) { + switch(parseLL(yytext)) { case 0: - sprintf(errstr,"bad int64 constant: %s",(char*)ncgtext); + sprintf(errstr,"bad int64 constant: %s",(char*)yytext); yyerror(errstr); break; case -1: token = INT64_CONST; break; @@ -1949,7 +1828,7 @@ YY_RULE_SETUP } break; default:/*(optionally)signed string of digits; treat like int*/ - sprintf(errstr,"bad numeric constant: %s",(char*)ncgtext); + sprintf(errstr,"bad numeric constant: %s",(char*)yytext); yyerror(errstr); } return lexdebug(token); @@ -1957,40 +1836,40 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 406 "ncgen.l" +#line 405 "ncgen.l" { - int slen = strlen(ncgtext); - int tag = ncgtext[slen-1]; + int slen = strlen(yytext); + int tag = yytext[slen-1]; int token = 0; switch (tag) { case 'B': case 'b': - if (sscanf((char*)ncgtext, "%u", &uint32_val) != 1 + if (sscanf((char*)yytext, "%u", &uint32_val) != 1 || uint32_val > NC_MAX_UBYTE) { - sprintf(errstr,"bad unsigned byte constant: %s",(char*)ncgtext); + sprintf(errstr,"bad unsigned byte constant: %s",(char*)yytext); yyerror(errstr); } ubyte_val = (unsigned char)uint32_val; token = UBYTE_CONST; break; case 'S': case 's': - if (sscanf((char*)ncgtext, "%u", &uint32_val) != 1 + if (sscanf((char*)yytext, "%u", &uint32_val) != 1 || uint32_val > NC_MAX_USHORT) { - sprintf(errstr,"bad unsigned short constant: %s",(char*)ncgtext); + sprintf(errstr,"bad unsigned short constant: %s",(char*)yytext); yyerror(errstr); } uint16_val = (unsigned short)uint32_val; token = USHORT_CONST; break; case 'L': case 'l': - if (sscanf((char*)ncgtext, "%llu", &uint64_val) != 1) { - sprintf(errstr,"bad unsigned int64 constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%llu", &uint64_val) != 1) { + sprintf(errstr,"bad unsigned int64 constant: %s",(char*)yytext); yyerror(errstr); } token = UINT64_CONST; break; default: /* string of digits; treat like int */ - if (sscanf((char*)ncgtext, "%u", &uint32_val) != 1) { - sprintf(errstr,"bad unsigned int constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%u", &uint32_val) != 1) { + sprintf(errstr,"bad unsigned int constant: %s",(char*)yytext); yyerror(errstr); } token = UINT_CONST; @@ -2000,15 +1879,15 @@ YY_RULE_SETUP YY_BREAK case 37: YY_RULE_SETUP -#line 445 "ncgen.l" +#line 444 "ncgen.l" { int c; int token = 0; - int slen = strlen(ncgtext); - int tag = ncgtext[slen-1]; - char* hex = ncgtext+2; /* point to first true hex digit */ + int slen = strlen(yytext); + int tag = yytext[slen-1]; + char* hex = yytext+2; /* point to first true hex digit */ int xlen = (slen - 3); /* true hex length */ - ncgtext[slen-1] = '\0'; + yytext[slen-1] = '\0'; if(xlen > 16) { /* truncate hi order digits */ hex += (xlen - 16); } @@ -2027,8 +1906,8 @@ YY_RULE_SETUP token = UINT64_CONST; break; default: /* should never happen */ - if (sscanf((char*)ncgtext, "%i", &uint32_val) != 1) { - sprintf(errstr,"bad unsigned int constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%i", &uint32_val) != 1) { + sprintf(errstr,"bad unsigned int constant: %s",(char*)yytext); yyerror(errstr); } token = UINT_CONST; @@ -2038,10 +1917,10 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 479 "ncgen.l" +#line 478 "ncgen.l" { - if (sscanf((char*)ncgtext, "%le", &double_val) != 1) { - sprintf(errstr,"bad long or double constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%le", &double_val) != 1) { + sprintf(errstr,"bad long or double constant: %s",(char*)yytext); yyerror(errstr); } return lexdebug(DOUBLE_CONST); @@ -2049,45 +1928,44 @@ YY_RULE_SETUP YY_BREAK case 39: YY_RULE_SETUP -#line 486 "ncgen.l" +#line 485 "ncgen.l" { - if (sscanf((char*)ncgtext, "%e", &float_val) != 1) { - sprintf(errstr,"bad float constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%e", &float_val) != 1) { + sprintf(errstr,"bad float constant: %s",(char*)yytext); yyerror(errstr); } return lexdebug(FLOAT_CONST); } YY_BREAK case 40: -/* rule 40 can match eol */ YY_RULE_SETUP -#line 493 "ncgen.l" +#line 492 "ncgen.l" { - (void) sscanf((char*)&ncgtext[1],"%c",&byte_val); + (void) sscanf((char*)&yytext[1],"%c",&byte_val); return lexdebug(BYTE_CONST); } YY_BREAK case 41: YY_RULE_SETUP -#line 497 "ncgen.l" +#line 496 "ncgen.l" { - byte_val = (char) strtol((char*)&ncgtext[2], (char **) 0, 8); + byte_val = (char) strtol((char*)&yytext[2], (char **) 0, 8); return lexdebug(BYTE_CONST); } YY_BREAK case 42: YY_RULE_SETUP -#line 501 "ncgen.l" +#line 500 "ncgen.l" { - byte_val = (char) strtol((char*)&ncgtext[3], (char **) 0, 16); + byte_val = (char) strtol((char*)&yytext[3], (char **) 0, 16); return lexdebug(BYTE_CONST); } YY_BREAK case 43: YY_RULE_SETUP -#line 505 "ncgen.l" +#line 504 "ncgen.l" { - switch ((char)ncgtext[2]) { + switch ((char)yytext[2]) { case 'a': byte_val = '\007'; break; /* not everyone under- * stands '\a' yet */ case 'b': byte_val = '\b'; break; @@ -2099,15 +1977,14 @@ YY_RULE_SETUP case '\\': byte_val = '\\'; break; case '?': byte_val = '\177'; break; case '\'': byte_val = '\''; break; - default: byte_val = (char)ncgtext[2]; + default: byte_val = (char)yytext[2]; } return lexdebug(BYTE_CONST); } YY_BREAK case 44: -/* rule 44 can match eol */ YY_RULE_SETUP -#line 523 "ncgen.l" +#line 522 "ncgen.l" { lineno++ ; break; @@ -2115,30 +1992,29 @@ YY_RULE_SETUP YY_BREAK case 45: YY_RULE_SETUP -#line 528 "ncgen.l" +#line 527 "ncgen.l" {/*initial*/ BEGIN(ST_C_COMMENT); break; } YY_BREAK case 46: -/* rule 46 can match eol */ YY_RULE_SETUP -#line 533 "ncgen.l" +#line 532 "ncgen.l" {/* continuation */ break; } YY_BREAK case 47: YY_RULE_SETUP -#line 537 "ncgen.l" +#line 536 "ncgen.l" {/* final */ BEGIN(INITIAL); break; } YY_BREAK case YY_STATE_EOF(ST_C_COMMENT): -#line 542 "ncgen.l" +#line 541 "ncgen.l" {/* final, error */ fprintf(stderr,"unterminated /**/ comment"); BEGIN(INITIAL); @@ -2147,17 +2023,17 @@ case YY_STATE_EOF(ST_C_COMMENT): YY_BREAK case 48: YY_RULE_SETUP -#line 548 "ncgen.l" +#line 547 "ncgen.l" {/* Note: this next rule will not work for UTF8 characters */ - return lexdebug(ncgtext[0]) ; + return lexdebug(yytext[0]) ; } YY_BREAK case 49: YY_RULE_SETUP -#line 551 "ncgen.l" +#line 550 "ncgen.l" ECHO; YY_BREAK -#line 2161 "lex.ncg.c" +#line 2037 "lex.ncg.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(TEXT): yyterminate(); @@ -2165,26 +2041,26 @@ case YY_STATE_EOF(TEXT): case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); + *yy_cp = yy_hold_char; YY_RESTORE_YY_MORE_OFFSET - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed ncgin at a new source and called - * ncglex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = ncgin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position @@ -2194,13 +2070,13 @@ case YY_STATE_EOF(TEXT): * end-of-buffer state). Contrast this with the test * in input(). */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state(); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -2213,41 +2089,41 @@ case YY_STATE_EOF(TEXT): yy_next_state = yy_try_NUL_trans( yy_current_state ); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_bp = yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); + yy_cp = ++yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { - yy_cp = (yy_c_buf_p); + yy_cp = yy_c_buf_p; goto yy_find_action; } } - else switch ( yy_get_next_buffer( ) ) + else switch ( yy_get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { - (yy_did_buffer_switch_on_eof) = 0; + yy_did_buffer_switch_on_eof = 0; - if ( ncgwrap( ) ) + if ( yywrap() ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * ncgtext, we can now set up + * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; @@ -2255,30 +2131,30 @@ case YY_STATE_EOF(TEXT): else { - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state(); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state(); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; @@ -2289,7 +2165,8 @@ case YY_STATE_EOF(TEXT): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -} /* end of ncglex */ + } /* end of yylex */ + /* yy_get_next_buffer - try to read in a new buffer * @@ -2298,20 +2175,21 @@ case YY_STATE_EOF(TEXT): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; register int number_to_move, i; int ret_val; - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + if ( yy_current_buffer->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. @@ -2331,30 +2209,34 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + YY_BUFFER_STATE b = yy_current_buffer; int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); + (int) (yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { @@ -2367,7 +2249,8 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - ncgrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ @@ -2377,35 +2260,35 @@ static int yy_get_next_buffer (void) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; - +#endif } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + yy_current_buffer->yy_n_chars = yy_n_chars; } - if ( (yy_n_chars) == 0 ) + if ( yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - ncgrestart(ncgin ); + yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + yy_current_buffer->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } @@ -2413,39 +2296,32 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ncgrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; return ret_val; -} + } + /* yy_get_previous_state - get the state just before the EOB char was reached */ - static yy_state_type yy_get_previous_state (void) -{ +static yy_state_type yy_get_previous_state() + { register yy_state_type yy_current_state; register char *yy_cp; - - yy_current_state = (yy_start); - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -2457,23 +2333,30 @@ static int yy_get_next_buffer (void) } return yy_current_state; -} + } + /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); + register char *yy_cp = yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -2485,73 +2368,80 @@ static int yy_get_next_buffer (void) yy_is_jam = (yy_current_state == 446); return yy_is_jam ? 0 : yy_current_state; -} + } - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - /* undo effects of setting up ncgtext */ - *yy_cp = (yy_hold_char); +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + &yy_current_buffer->yy_ch_buf[number_to_move]; - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + while ( source > yy_current_buffer->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} -#ifndef YY_NO_INPUT + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + #ifdef __cplusplus - static int yyinput (void) +static int yyinput() #else - static int input (void) +static int input() #endif - -{ + { int c; - - *(yy_c_buf_p) = (yy_hold_char); - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; + *yy_c_buf_p = '\0'; else { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; - switch ( yy_get_next_buffer( ) ) + switch ( yy_get_next_buffer() ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() @@ -2565,16 +2455,16 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - ncgrestart(ncgin ); + yyrestart( yyin ); - /*FALLTHROUGH*/ + /* fall through */ case EOB_ACT_END_OF_FILE: { - if ( ncgwrap( ) ) + if ( yywrap() ) return EOF; - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); @@ -2584,169 +2474,172 @@ static int yy_get_next_buffer (void) } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; + yy_c_buf_p = yytext_ptr + offset; break; } } } - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve ncgtext */ - (yy_hold_char) = *++(yy_c_buf_p); + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void ncgrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - ncgensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - ncg_create_buffer(ncgin,YY_BUF_SIZE ); } - ncg_init_buffer(YY_CURRENT_BUFFER,input_file ); - ncg_load_buffer_state( ); -} -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void ncg_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * ncgpop_buffer_state(); - * ncgpush_buffer_state(new_buffer); - */ - ncgensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) return; - if ( YY_CURRENT_BUFFER ) + if ( yy_current_buffer ) { /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; } - YY_CURRENT_BUFFER_LVALUE = new_buffer; - ncg_load_buffer_state( ); + yy_current_buffer = new_buffer; + yy_load_buffer_state(); /* We don't actually know whether we did this switch during - * EOF (ncgwrap()) processing, but the only time this flag - * is looked at is after ncgwrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ - (yy_did_buffer_switch_on_eof) = 1; -} + yy_did_buffer_switch_on_eof = 1; + } -static void ncg_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - ncgin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE ncg_create_buffer (FILE * file, int size ) -{ +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) ncgalloc(sizeof( struct yy_buffer_state ) ); + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) ncgalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - ncg_init_buffer(b,file ); + yy_init_buffer( b, file ); return b; -} + } -/** Destroy the buffer. - * @param b a buffer created with ncg_create_buffer() - * - */ - void ncg_delete_buffer (YY_BUFFER_STATE b ) -{ - + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { if ( ! b ) return; - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - ncgfree((void *) b->yy_ch_buf ); + yy_flex_free( (void *) b->yy_ch_buf ); - ncgfree((void *) b ); -} + yy_flex_free( (void *) b ); + } -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a ncgrestart() or at EOF. - */ - static void ncg_init_buffer (YY_BUFFER_STATE b, FILE * file ) -{ - int oerrno = errno; - - ncg_flush_buffer(b ); +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then ncg_init_buffer was _probably_ - * called from ncgrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void ncg_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) return; b->yy_n_chars = 0; @@ -2763,127 +2656,31 @@ extern int isatty (int ); b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == YY_CURRENT_BUFFER ) - ncg_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - ncgensure_buffer_stack(); - - /* This block is copied from ncg_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from ncg_switch_to_buffer. */ - ncg_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void ncgpop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - ncg_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - ncg_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void ncgensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)ncgalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in ncgensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; + if ( b == yy_current_buffer ) + yy_load_buffer_state(); } - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)ncgrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in ncgensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE ncg_scan_buffer (char * base, yy_size_t size ) -{ +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; - b = (YY_BUFFER_STATE) ncgalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; @@ -2895,53 +2692,58 @@ YY_BUFFER_STATE ncg_scan_buffer (char * base, yy_size_t size ) b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - ncg_switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; -} + } +#endif -/** Setup the input buffer state to scan a string. The next call to ncglex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * ncg_scan_bytes() instead. - */ -YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr ) -{ - - return ncg_scan_bytes(yystr,strlen(yystr) ); -} -/** Setup the input buffer state to scan the given bytes. The next call to ncglex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) ncgalloc(n ); + n = len + 2; + buf = (char *) yy_flex_alloc( n ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - b = ncg_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in ncg_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2949,17 +2751,78 @@ YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, int _yybytes_len ) b->yy_is_our_buffer = 1; return b; -} + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); -} + } + + /* Redefine yyless() so it works in section 3 code. */ @@ -2967,178 +2830,69 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up ncgtext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - ncgtext[ncgleng] = (yy_hold_char); \ - (yy_c_buf_p) = ncgtext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - ncgleng = yyless_macro_arg; \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ } \ while ( 0 ) -/* Accessor methods (get/set functions) to struct members. */ -/** Get the current line number. - * - */ -int ncgget_lineno (void) -{ - - return ncglineno; -} - -/** Get the input stream. - * - */ -FILE *ncgget_in (void) -{ - return ncgin; -} - -/** Get the output stream. - * - */ -FILE *ncgget_out (void) -{ - return ncgout; -} - -/** Get the length of the current token. - * - */ -int ncgget_leng (void) -{ - return ncgleng; -} - -/** Get the current token. - * - */ - -char *ncgget_text (void) -{ - return ncgtext; -} - -/** Set the current line number. - * @param line_number - * - */ -void ncgset_lineno (int line_number ) -{ - - ncglineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see ncg_switch_to_buffer - */ -void ncgset_in (FILE * in_str ) -{ - ncgin = in_str ; -} - -void ncgset_out (FILE * out_str ) -{ - ncgout = out_str ; -} - -int ncgget_debug (void) -{ - return ncg_flex_debug; -} - -void ncgset_debug (int bdebug ) -{ - ncg_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from ncglex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - ncgin = stdin; - ncgout = stdout; -#else - ncgin = (FILE *) 0; - ncgout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * ncglex_init() - */ - return 0; -} - -/* ncglex_destroy is for both reentrant and non-reentrant scanners. */ -int ncglex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - ncg_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - ncgpop_buffer_state(); - } - - /* Destroy the stack itself. */ - ncgfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * ncglex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ +/* Internal utility routines. */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; -} + } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { register int n; for ( n = 0; s[n]; ++n ) ; return n; -} + } #endif -void *ncgalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} -void *ncgrealloc (void * ptr, yy_size_t size ) -{ +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -3147,24 +2901,33 @@ void *ncgrealloc (void * ptr, yy_size_t size ) * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); -} + } -void ncgfree (void * ptr ) -{ - free( (char *) ptr ); /* see ncgrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 551 "ncgen.l" +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 550 "ncgen.l" static int lexdebug(int token) { if(debug >= 2) { - fprintf(stderr,"Token=%d |%s|\n",token,ncgtext); + fprintf(stderr,"Token=%d |%s|\n",token,yytext); } return token; } @@ -3272,4 +3035,3 @@ parseLL(char* text) #endif /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/ return result; } -