glr: examples: fix locations

The locations are actually false: they should include the location of
the semicolon (we print statements), but they don't.

* examples/c++/glr/c++-types.test, examples/c++/glr/c++-types.yy,
* examples/c/glr/c++-types.test, examples/c/glr/c++-types.y,
* tests/cxx-type.at:
Fix locations and adjust expectations.
This commit is contained in:
Akim Demaille
2021-01-10 16:28:54 +01:00
parent 5433b0a84b
commit 3bcc090758
5 changed files with 39 additions and 39 deletions

View File

@@ -25,10 +25,10 @@ T x = y;
x = y;
EOF
run 0 "\
1.0-4: +(z, q)
3.0-2: <declare>(T, x)
5.0-6: <init-declare>(T, x, y)
7.0-4: =(x, y)"
1.0-5: +(z, q)
3.0-3: <declare>(T, x)
5.0-7: <init-declare>(T, x, y)
7.0-5: =(x, y)"
cat >input <<EOF
T (x) + y;
@@ -42,9 +42,9 @@ T (y y) = z + q;
z + q;
EOF
run 0 "\
1.0-8: +(<cast>(x, T), y)
3.0-4: <OR>(<declare>(T, x), <cast>(x, T))
5.0-12: <OR>(<init-declare>(T, y, +(z, q)), =(<cast>(y, T), +(z, q)))
7.0-14: <error>
9.0-4: +(z, q)
1.0-9: +(<cast>(x, T), y)
3.0-5: <OR>(<declare>(T, x), <cast>(x, T))
5.0-13: <OR>(<init-declare>(T, y, +(z, q)), =(<cast>(y, T), +(z, q)))
7.0-15: <error>
9.0-5: +(z, q)
err: 7.5: syntax error, unexpected identifier, expecting '=' or '+' or ')'"

View File

@@ -157,7 +157,7 @@ yylex (yy::parser::value_type* lvalp, yy::parser::location_type* llocp)
tok = c;
lvalp = nullptr;
}
llocp->end.column = colNum-1;
llocp->end.column = colNum;
return tok;
}
}

View File

@@ -35,13 +35,13 @@ T (y y) = z + q;
z + q;
EOF
run 0 "\
1.0-4: +(z, q)
3.0-2: <declare>(T, x)
5.0-6: <init-declare>(T, x, y)
7.0-4: =(x, y)
9.0-8: +(<cast>(x, T), y)
11.0-4: <OR>(<declare>(T, x), <cast>(x, T))
13.0-12: <OR>(<init-declare>(T, y, +(z, q)), =(<cast>(y, T), +(z, q)))
15.0-14: <error>
17.0-4: +(z, q)
1.0-5: +(z, q)
3.0-3: <declare>(T, x)
5.0-7: <init-declare>(T, x, y)
7.0-5: =(x, y)
9.0-9: +(<cast>(x, T), y)
11.0-5: <OR>(<declare>(T, x), <cast>(x, T))
13.0-13: <OR>(<init-declare>(T, y, +(z, q)), =(<cast>(y, T), +(z, q)))
15.0-15: <error>
17.0-5: +(z, q)
err: 15.5: syntax error, unexpected identifier, expecting '=' or '+' or ')'"

View File

@@ -199,7 +199,7 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
colNum += 1;
tok = c;
}
llocp->last_column = colNum-1;
llocp->last_column = colNum;
return tok;
}
}