X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/147e184ccc8bbdfb5111c773118902836370e2af..62a3e4f0c54505834cb89c40726771ad32aabb27:/tests/calc.at diff --git a/tests/calc.at b/tests/calc.at index 5fa17f44..f813c462 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -63,9 +63,16 @@ static void yyungetc (int c); extern void perror (const char *s); %} +/* Also exercise %union. */ +%union +{ + int ival; /* A comment to exercise an old bug. */ +}; + /* Bison Declarations */ -%token CALC_EOF 0 -%token NUM +%token CALC_EOF 0 "end of file" +%token NUM "number" +%type exp %nonassoc '=' /* comparison */ %left '-' '+' @@ -78,13 +85,13 @@ extern void perror (const char *s); /* Grammar follows */ %% input: - /* empty string */ + line | input line ; line: '\n' -| exp '\n' +| exp '\n' {} ; exp: @@ -118,11 +125,16 @@ yyerror (const char *s) fprintf (stderr, "%s\n", s); } + +#if YYLSP_NEEDED +static YYLTYPE last_yylloc; +#endif static int yygetc (void) { int res = getc (yyin); #if YYLSP_NEEDED + last_yylloc = yylloc; if (res == '\n') { yylloc.last_line++; @@ -140,7 +152,7 @@ yyungetc (int c) { #if YYLSP_NEEDED /* Wrong when C == `\n'. */ - yylloc.last_column--; + yylloc = last_yylloc; #endif ungetc (c, yyin); } @@ -200,7 +212,7 @@ yylex (void) if (c == '.' || isdigit (c)) { yyungetc (c); - yylval = read_signed_integer (); + yylval.ival = read_signed_integer (); return NUM; } @@ -273,7 +285,7 @@ m4_define([_AT_CHECK_CALC], [AT_DATA([[input]], [[$2 ]]) -AT_CHECK([calc input], 0, [], [stderr])dnl +AT_CHECK([./calc input], 0, [], [stderr])dnl AT_CHECK([wc -l