mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 07:13:02 +00:00
yacc.c, glr.c: a better YY_LOCATION_PRINT
* data/c.m4 (b4_yy_location_print_define): New. Now issues "short" locations, e.g., "1.1" instead of "1.1-1.1". Was initially a function, but then we face "static but unused" warnings. Simpler as a macro. * tests/local.at, data/glr.c, data/yacc.c: Use it instead of duplicating. * tests/actions.at: Adjust expectations.
This commit is contained in:
@@ -651,29 +651,29 @@ AT_PARSER_CHECK([./input], 1,
|
||||
]],
|
||||
[[Starting parse
|
||||
Entering state 0
|
||||
Reading a token: Next token is token 'a' (1.1-1.1: <> printer for 'a' @ 1)
|
||||
Shifting token 'a' (1.1-1.1: <> printer for 'a' @ 1)
|
||||
Reading a token: Next token is token 'a' (1.1: <> printer for 'a' @ 1)
|
||||
Shifting token 'a' (1.1: <> printer for 'a' @ 1)
|
||||
Entering state 1
|
||||
Reading a token: Next token is token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
|
||||
Shifting token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
|
||||
Reading a token: Next token is token 'b' (1.2: 'b'/'c' printer for 'b' @ 2)
|
||||
Shifting token 'b' (1.2: 'b'/'c' printer for 'b' @ 2)
|
||||
Entering state 3
|
||||
Reading a token: Next token is token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
|
||||
Shifting token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
|
||||
Reading a token: Next token is token 'c' (1.3: 'b'/'c' printer for 'c' @ 3)
|
||||
Shifting token 'c' (1.3: 'b'/'c' printer for 'c' @ 3)
|
||||
Entering state 5
|
||||
Reading a token: Next token is token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
||||
Shifting token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
||||
Reading a token: Next token is token 'd' (1.4: <> printer for 'd' @ 4)
|
||||
Shifting token 'd' (1.4: <> printer for 'd' @ 4)
|
||||
Entering state 6
|
||||
Reading a token: Now at end of input.
|
||||
1.5: syntax error, unexpected $end, expecting 'e'
|
||||
Error: popping token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
||||
Error: popping token 'd' (1.4: <> printer for 'd' @ 4)
|
||||
Stack now 0 1 3 5
|
||||
Error: popping token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
|
||||
Error: popping token 'c' (1.3: 'b'/'c' printer for 'c' @ 3)
|
||||
Stack now 0 1 3
|
||||
Error: popping token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
|
||||
Error: popping token 'b' (1.2: 'b'/'c' printer for 'b' @ 2)
|
||||
Stack now 0 1
|
||||
Error: popping token 'a' (1.1-1.1: <> printer for 'a' @ 1)
|
||||
Error: popping token 'a' (1.1: <> printer for 'a' @ 1)
|
||||
Stack now 0
|
||||
Cleanup: discarding lookahead token $end (1.5-1.5: )
|
||||
Cleanup: discarding lookahead token $end (1.5: )
|
||||
Stack now 0
|
||||
]])
|
||||
|
||||
@@ -895,15 +895,15 @@ AT_PARSER_CHECK([./input$1], 0,
|
||||
[[Starting parse
|
||||
Entering state 0
|
||||
Reducing stack by rule 1 (line 46):
|
||||
-> $$ = nterm start (1.1-1.1: <]]kind[[> for 'S' @ 1)
|
||||
-> $$ = nterm start (1.1: <]]kind[[> for 'S' @ 1)
|
||||
Stack now 0
|
||||
Entering state 1
|
||||
Reading a token: Now at end of input.
|
||||
Shifting token END (1.1-1.1: <]]kind[[> for 'E' @ 1)
|
||||
Shifting token END (1.1: <]]kind[[> for 'E' @ 1)
|
||||
Entering state 2
|
||||
Stack now 0 1 2
|
||||
Cleanup: popping token END (1.1-1.1: <]]kind[[> for 'E' @ 1)
|
||||
Cleanup: popping nterm start (1.1-1.1: <]]kind[[> for 'S' @ 1)
|
||||
Cleanup: popping token END (1.1: <]]kind[[> for 'E' @ 1)
|
||||
Cleanup: popping nterm start (1.1: <]]kind[[> for 'S' @ 1)
|
||||
]])
|
||||
|
||||
m4_popdef([kind])
|
||||
|
||||
@@ -386,14 +386,7 @@ static
|
||||
[[^,]+[^A-Za-z_0-9]\([A-Za-z_][A-Za-z_0-9]*\), *], [
|
||||
YYUSE(\1);])dnl
|
||||
AT_YYERROR_SEES_LOC_IF([[
|
||||
fprintf (stderr, "%d.%d",
|
||||
]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[);
|
||||
if (]AT_LOC_FIRST_LINE[ < ]AT_LOC_LAST_LINE[)
|
||||
fprintf (stderr, "-%d.%d",
|
||||
]AT_LOC_LAST_LINE[, ]AT_LOC_LAST_COLUMN[ - 1);
|
||||
else if (]AT_LOC_FIRST_COLUMN[ < ]AT_LOC_LAST_COLUMN[ - 1)
|
||||
fprintf (stderr, "-%d",
|
||||
]AT_LOC_LAST_COLUMN[ - 1);
|
||||
YY_LOCATION_PRINT (stderr, ]AT_LOC[);
|
||||
fprintf (stderr, ": ");]])[
|
||||
fprintf (stderr, "%s\n", msg);
|
||||
}]],
|
||||
|
||||
Reference in New Issue
Block a user