X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/0de741ca660c2d8f337600c45326b2a3e25bf131..403b315bb1f3b9b61630cf123f348cb19070dd6c:/src/bison.s1 diff --git a/src/bison.s1 b/src/bison.s1 index c10cee41..62859b27 100644 --- a/src/bison.s1 +++ b/src/bison.s1 @@ -1,5 +1,5 @@ /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "bison.simple" +#line /* This file comes from bison-@bison_version@. */ /* Skeleton output parser for bison, @@ -132,24 +132,26 @@ while (0) # endif /* not YYLSP_NEEDED */ #endif -/* If nonreentrant, generate the variables here */ +/* If nonreentrant, generate the variables here. */ #ifndef YYPURE +/* The lookahead symbol. */ +int yychar; -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; # ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ +/* Location data for the lookahead symbol. */ +YYLTYPE yylloc; # endif -int yynerrs; /* number of parse errors so far */ +/* Number of parse errors so far. */ +int yynerrs; #endif /* not YYPURE */ -#if YYDEBUG != 0 +#if YYDEBUG int yydebug; /* nonzero means print parse trace */ /* [The following comment makes no sense to me. Could someone @@ -222,7 +224,7 @@ __yy_memcpy (char *to, char *from, unsigned int count) # endif #endif -#line 217 "bison.simple" +#line /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. @@ -307,10 +309,15 @@ yyparse(YYPARSE_PARAM_ARG) #endif - /* The variable used to return semantic values from the action - routines. */ + /* The variables used to return semantic value and location from the + action routines. */ YYSTYPE yyval; +# ifdef YYLSP_NEEDED + YYLTYPE yyloc; +# endif + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ int yylen; if (yydebug) @@ -463,16 +470,20 @@ yynewstate: { yychar1 = YYTRANSLATE(yychar); +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables + which are defined only if `YYDEBUG' is set. */ if (yydebug) { fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ + /* Give the individual parser a way to print the precise + meaning of a token, for further debugging info. */ # ifdef YYPRINT YYPRINT (stderr, yychar, yylval); # endif fprintf (stderr, ")\n"); } +#endif } yyn += yychar1; @@ -502,9 +513,10 @@ yynewstate: YYACCEPT; /* Shift the lookahead token. */ - +#if YYDEBUG if (yydebug) fprintf (stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) @@ -531,8 +543,27 @@ yydefault: /* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: yylen = yyr2[yyn]; + /* Implement default value of the action: + `{dollar}{dollar} = {dollar}1'. */ + if (yylen > 0) + yyval = yyvsp[1-yylen]; +#ifdef YYLSP_NEEDED + /* Implement default location. If the rhs is empty, extend YYLOC to + YYLLOC, which corresponds to the current token, otherwise + implement `@{dollar} = Starts at @1, ends at @YYLEN'. */ if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ + { + yyloc = yylsp[1-yylen]; + yyloc.last_line = yylsp[0].last_line; + yyloc.last_column = yylsp[0].last_column; + } + else + { + yyloc.last_line = yylsp[0].last_line; + yyloc.last_column = yylsp[0].last_column; + yyloc.text = 0; + } +#endif #if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which @@ -551,7 +582,7 @@ yyreduce: } #endif $ /* the action file gets copied in in place of this dollarsign */ -#line 543 "bison.simple" +#line yyvsp -= yylen; yyssp -= yylen; @@ -569,28 +600,13 @@ $ /* the action file gets copied in in place of this dollarsign */ } *++yyvsp = yyval; - #ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_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 = yyloc; #endif - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ yyn = yyr1[yyn]; @@ -624,10 +640,14 @@ yyerrlab: /* here on detecting error */ x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); + size += strlen ("parse error, unexpected `") + 1; + size += strlen (yytname[YYTRANSLATE (yychar)]); + msg = (char *) malloc (size); if (msg != 0) { - strcpy(msg, "parse error"); + strcpy (msg, "parse error, unexpected `"); + strcat (msg, yytname[YYTRANSLATE (yychar)]); + strcat (msg, "'"); if (count < 5) { @@ -636,21 +656,21 @@ yyerrlab: /* here on detecting error */ x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); + strcat (msg, count == 0 ? ", expecting `" : " or `"); + strcat (msg, yytname[x]); + strcat (msg, "'"); count++; } } - yyerror(msg); - free(msg); + yyerror (msg); + free (msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ - yyerror("parse error"); + yyerror ("parse error"); } goto yyerrlab1; @@ -663,11 +683,11 @@ yyerrlab1: /* here on error raised explicitly by an action */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; - +#if YYDEBUG if (yydebug) fprintf (stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); - +#endif yychar = YYEMPTY; }