[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/11] glr: examples: fix locations
From: |
Akim Demaille |
Subject: |
[PATCH 04/11] glr: examples: fix locations |
Date: |
Sun, 10 Jan 2021 17:59:03 +0100 |
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.
---
examples/c++/glr/c++-types.test | 18 ++++++++--------
examples/c++/glr/c++-types.yy | 2 +-
examples/c/glr/c++-types.test | 18 ++++++++--------
examples/c/glr/c++-types.y | 2 +-
tests/cxx-type.at | 38 ++++++++++++++++-----------------
5 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/examples/c++/glr/c++-types.test b/examples/c++/glr/c++-types.test
index a814d363..6a00cd8c 100644
--- a/examples/c++/glr/c++-types.test
+++ b/examples/c++/glr/c++-types.test
@@ -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 ')'"
diff --git a/examples/c++/glr/c++-types.yy b/examples/c++/glr/c++-types.yy
index 9b649f52..975ed71f 100644
--- a/examples/c++/glr/c++-types.yy
+++ b/examples/c++/glr/c++-types.yy
@@ -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;
}
}
diff --git a/examples/c/glr/c++-types.test b/examples/c/glr/c++-types.test
index 079538c3..a476bb86 100644
--- a/examples/c/glr/c++-types.test
+++ b/examples/c/glr/c++-types.test
@@ -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 ')'"
diff --git a/examples/c/glr/c++-types.y b/examples/c/glr/c++-types.y
index f99e0426..46fcb171 100644
--- a/examples/c/glr/c++-types.y
+++ b/examples/c/glr/c++-types.y
@@ -199,7 +199,7 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
colNum += 1;
tok = c;
}
- llocp->last_column = colNum-1;
+ llocp->last_column = colNum;
return tok;
}
}
diff --git a/tests/cxx-type.at b/tests/cxx-type.at
index 64568ae9..3181e47a 100644
--- a/tests/cxx-type.at
+++ b/tests/cxx-type.at
@@ -208,7 +208,7 @@ main (int argc, char **argv)
tok = c;
yylval = YY_NULLPTR;
}]AT_LOCATION_IF([[
- yylloc.last_column = colNum-1;]])[
+ yylloc.last_column = colNum;]])[
return tok;
}
}
@@ -344,15 +344,15 @@ m4_define([_AT_RESOLVED_GLR_OUTPUT],
]])
m4_define([_AT_RESOLVED_GLR_OUTPUT_WITH_LOC],
-[[3.0-3.5: +(z,q)
-5.0-5.3: <declare>(T,x)
-7.0-7.7: <init-declare>(T,x,y)
-9.0-9.5: =(x,y)
-11.0-11.9: +(<cast>(x,T),y)
-13.0-13.5: <declare>(T,x)
-15.0-15.13: <init-declare>(T,y,+(z,q))
-17.0-17.15: <error>
-19.0-19.5: +(z,q)
+[[3.0-3.6: +(z,q)
+5.0-5.4: <declare>(T,x)
+7.0-7.8: <init-declare>(T,x,y)
+9.0-9.6: =(x,y)
+11.0-11.10: +(<cast>(x,T),y)
+13.0-13.6: <declare>(T,x)
+15.0-15.14: <init-declare>(T,y,+(z,q))
+17.0-17.16: <error>
+19.0-19.6: +(z,q)
]])
m4_define([_AT_AMBIG_GLR_OUTPUT],
@@ -368,15 +368,15 @@ m4_define([_AT_AMBIG_GLR_OUTPUT],
]])
m4_define([_AT_AMBIG_GLR_OUTPUT_WITH_LOC],
-[[3.0-3.5: +(z,q)
-5.0-5.3: <declare>(T,x)
-7.0-7.7: <init-declare>(T,x,y)
-9.0-9.5: =(x,y)
-11.0-11.9: +(<cast>(x,T),y)
-13.0-13.5: <OR>(<declare>(T,x),<cast>(x,T))
-15.0-15.13: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
-17.0-17.15: <error>
-19.0-19.5: +(z,q)
+[[3.0-3.6: +(z,q)
+5.0-5.4: <declare>(T,x)
+7.0-7.8: <init-declare>(T,x,y)
+9.0-9.6: =(x,y)
+11.0-11.10: +(<cast>(x,T),y)
+13.0-13.6: <OR>(<declare>(T,x),<cast>(x,T))
+15.0-15.14: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
+17.0-17.16: <error>
+19.0-19.6: +(z,q)
]])
m4_define([_AT_GLR_STDERR],
--
2.30.0
- [PATCH 00/11] glr2.cc: add support for token constructors, Akim Demaille, 2021/01/10
- [PATCH 01/11] tests: fix definition for parser class name, Akim Demaille, 2021/01/10
- [PATCH 02/11] glr: tests: formatting changes, Akim Demaille, 2021/01/10
- [PATCH 03/11] glr: tests: more macros, Akim Demaille, 2021/01/10
- [PATCH 04/11] glr: examples: fix locations,
Akim Demaille <=
- [PATCH 05/11] glr2.cc: fix memory leak, Akim Demaille, 2021/01/10
- [PATCH 06/11] glr2.cc: use references to print symbols, Akim Demaille, 2021/01/10
- [PATCH 07/11] glr2.cc: example: style changes, Akim Demaille, 2021/01/10
- [PATCH 08/11] glr2.cc: rely on symbol kinds rather than token kinds, Akim Demaille, 2021/01/10
- [PATCH 09/11] glr2.cc: tests: simplify, Akim Demaille, 2021/01/10
- [PATCH 11/11] glr2.cc: add support for api.token.constructor, Akim Demaille, 2021/01/10
- [PATCH 10/11] glr2.cc: introduce the yytranslate_ member function, Akim Demaille, 2021/01/10