X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/573c1d9ff8aca759e7d01405c809b0318e2edfb2..b85810aec0e5172c813b1cdd511bfce8a0cd4b4f:/src/bison.hairy diff --git a/src/bison.hairy b/src/bison.hairy index 3acb54bc..1034eae7 100644 --- a/src/bison.hairy +++ b/src/bison.hairy @@ -1,83 +1,89 @@ - /* -*- C -*- */ -extern int timeclock; +%%{section} %%{output-prefix} %%{output-infix} %%".c" + /* -*- C -*- */ +/* YYERROR and YYCOST are set by guards. If yyerror is set to a + nonzero value by a guard, the reduction with which the guard is + associated is not performed, and the error recovery mechanism is + invoked. Yycost indicates the cost of performing the reduction + given the attributes of the symbols. */ +static int yyerror; +static int yycost; -int yyerror; /* Yyerror and yycost are set by guards. */ -int yycost; /* If yyerror is set to a nonzero value by a */ - /* guard, the reduction with which the guard */ - /* is associated is not performed, and the */ - /* error recovery mechanism is invoked. */ - /* Yycost indicates the cost of performing */ - /* the reduction given the attributes of the */ - /* symbols. */ - - -/* YYMAXDEPTH indicates the size of the parser's state and value */ -/* stacks. */ +/* YYMAXDEPTH indicates the size of the parser's state and value + stacks. */ #ifndef YYMAXDEPTH -#define YYMAXDEPTH 500 +# define YYMAXDEPTH 500 #endif -/* YYMAXRULES must be at least as large as the number of rules that */ -/* could be placed in the rule queue. That number could be determined */ -/* from the grammar and the size of the stack, but, as yet, it is not. */ +/* YYMAXRULES must be at least as large as the number of rules that + could be placed in the rule queue. That number could be determined + from the grammar and the size of the stack, but, as yet, it is not. + */ #ifndef YYMAXRULES -#define YYMAXRULES 100 +# define YYMAXRULES 100 #endif #ifndef YYMAXBACKUP -#define YYMAXBACKUP 100 +# define YYMAXBACKUP 100 #endif -short yyss[YYMAXDEPTH]; /* the state stack */ -YYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */ -YYLTYPE yyls[YYMAXDEPTH]; /* the location stack */ -short yyrq[YYMAXRULES]; /* the rule queue */ -int yychar; /* the lookahead symbol */ +/* The state stack. */ +static short yyss[YYMAXDEPTH]; +/* The semantic value stack. */ +static YYSTYPE yyvs[YYMAXDEPTH]; +/* The location stack. */ +static YYLTYPE yyls[YYMAXDEPTH]; +/* The rule queue. */ +static short yyrq[YYMAXRULES]; +/* The lookahead symbol. */ +static int yychar; -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ +/* the semantic value of the lookahead symbol. */ +static YYSTYPE yylval; -YYSTYPE yytval; /* the semantic value for the state */ - /* at the top of the state stack. */ +/* the semantic value for the state at the top of the state stack. */ +static YYSTYPE yytval; -YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ +/* the variable used to return semantic values from the action + routines. */ +static YYSTYPE yyval; -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ +/* location data for the lookahead symbol. */ +static YYLTYPE yylloc; -YYLTYPE yytloc; /* location data for the state at the */ - /* top of the state stack */ +/* location data for the state at the top of the state stack. */ +static YYLTYPE yytloc; -int yynunlexed; -short yyunchar[YYMAXBACKUP]; -YYSTYPE yyunval[YYMAXBACKUP]; -YYLTYPE yyunloc[YYMAXBACKUP]; +static int yynunlexed; +static short yyunchar[YYMAXBACKUP]; +static YYSTYPE yyunval[YYMAXBACKUP]; +static YYLTYPE yyunloc[YYMAXBACKUP]; -short *yygssp; /* a pointer to the top of the state */ - /* stack; only set during error */ - /* recovery. */ +/* a pointer to the top of the state stack; only set during error + recovery. */ +static short *yygssp; -YYSTYPE *yygvsp; /* a pointer to the top of the value */ - /* stack; only set during error */ - /* recovery. */ +/* a pointer to the top of the value stack; only set during error + recovery. */ +static YYSTYPE *yygvsp; -YYLTYPE *yyglsp; /* a pointer to the top of the */ - /* location stack; only set during */ - /* error recovery. */ +/* a pointer to the top of the location stack; only set during error + recovery. */ +static YYLTYPE *yyglsp; -/* Yyget is an interface between the parser and the lexical analyzer. */ -/* It is costly to provide such an interface, but it avoids requiring */ -/* the lexical analyzer to be able to back up the scan. */ +/*--------------------------------------------------------------------. +| Yyget is an interface between the parser and the lexical analyzer. | +| It is costly to provide such an interface, but it avoids requiring | +| the lexical analyzer to be able to back up the scan. | +`--------------------------------------------------------------------*/ -yyget() +static inline void +yyget (void) { if (yynunlexed > 0) { @@ -90,19 +96,17 @@ yyget() yychar = 0; else { - yychar = yylex(); + yychar = yylex (); if (yychar < 0) yychar = 0; - else yychar = YYTRANSLATE(yychar); + else + yychar = YYTRANSLATE (yychar); } } - -yyunlex(chr, val, loc) -int chr; -YYSTYPE val; -YYLTYPE loc; +static inline void +yyunlex (int chr, YYSTYPE val, YYLTYPE loc) { yyunchar[yynunlexed] = chr; yyunval[yynunlexed] = val; @@ -111,19 +115,17 @@ YYLTYPE loc; } - -yyrestore(first, last) -register short *first; -register short *last; +static inline void +yyrestore (short *first, short *last) { - register short *ssp; - register short *rp; - register int symbol; - register int state; - register int tvalsaved; + short *ssp; + short *rp; + int symbol; + int state; + int tvalsaved; ssp = yygssp; - yyunlex(yychar, yylval, yylloc); + yyunlex (yychar, yylval, yylloc); tvalsaved = 0; while (first != last) @@ -131,7 +133,7 @@ register short *last; symbol = yystos[*ssp]; if (symbol < YYNTBASE) { - yyunlex(symbol, yytval, yytloc); + yyunlex (symbol, yytval, yytloc); tvalsaved = 1; ssp--; } @@ -161,9 +163,9 @@ register short *last; } } - if ( ! tvalsaved && ssp > yyss) + if (!tvalsaved && ssp > yyss) { - yyunlex(yystos[*ssp], yytval, yytloc); + yyunlex (yystos[*ssp], yytval, yytloc); ssp--; } @@ -173,14 +175,14 @@ register short *last; int -yyparse() +yyparse (void) { - register int yystate; - register int yyn; - register short *yyssp; - register short *yyrq0; - register short *yyptr; - register YYSTYPE *yyvsp; + int yystate; + int yyn; + short *yyssp; + short *yyrq0; + short *yyptr; + YYSTYPE *yyvsp; int yylen; YYLTYPE *yylsp; @@ -195,16 +197,17 @@ yyparse() yyrq1 = yyrq0; yyrq2 = yyrq0; - yychar = yylex(); + yychar = yylex (); if (yychar < 0) yychar = 0; - else yychar = YYTRANSLATE(yychar); + else + yychar = YYTRANSLATE (yychar); yynewstate: if (yyssp >= yyss + YYMAXDEPTH - 1) { - yyabort("Parser Stack Overflow"); + yyabort ("Parser Stack Overflow"); YYABORT; } @@ -239,31 +242,30 @@ yyresume: yyvsp -= yylen; yylsp -= yylen; - yyguard(yyn, yyvsp, yylsp); + yyguard (yyn, yyvsp, yylsp); if (yyerror) goto yysemerr; - yyaction(yyn, yyvsp, yylsp); + yyaction (yyn, yyvsp, yylsp); *++yyvsp = yyval; yylsp++; if (yylen == 0) { - yylsp->timestamp = timeclock; yylsp->first_line = yytloc.first_line; yylsp->first_column = yytloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; + yylsp->last_line = (yylsp - 1)->last_line; + yylsp->last_column = (yylsp - 1)->last_column; yylsp->text = 0; } else { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; + yylsp->last_line = (yylsp + yylen - 1)->last_line; + yylsp->last_column = (yylsp + yylen - 1)->last_column; } if (yyptr == yyrq + YYMAXRULES) - yyptr = yyrq; + yyptr = yyrq; } if (yystate == YYFINAL) @@ -276,7 +278,7 @@ yyresume: *++yylsp = yytloc; yytval = yylval; yytloc = yylloc; - yyget(); + yyget (); goto yynewstate; @@ -295,7 +297,7 @@ yyreduce: if (yyrq0 == yyrq2) { - yyabort("Parser Rule Queue Overflow"); + yyabort ("Parser Rule Queue Overflow"); YYABORT; } @@ -320,8 +322,8 @@ yyerrlab: yygssp = yyssp; yygvsp = yyvsp; yyglsp = yylsp; - yyrestore(yyrq0, yyrq2); - yyrecover(); + yyrestore (yyrq0, yyrq2); + yyrecover (); yystate = *yygssp; yyssp = yygssp; yyvsp = yygvsp; @@ -331,4 +333,4 @@ yyerrlab: goto yyresume; } -%% actions +%%{actions}