[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/7] bistromathic: don't display undefined locations
From: |
Akim Demaille |
Subject: |
[PATCH 6/7] bistromathic: don't display undefined locations |
Date: |
Sun, 28 Jun 2020 16:52:19 +0200 |
Currently, completion when there is a syntax error shows broken
locations.
* examples/c/bistromathic/parse.y (expected_tokens): Initialize the
location.
* examples/c/bistromathic/bistromathic.test: Check that.
---
examples/c/bistromathic/bistromathic.test | 14 ++++++++++++++
examples/c/bistromathic/parse.y | 2 +-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/examples/c/bistromathic/bistromathic.test
b/examples/c/bistromathic/bistromathic.test
index c2d3dc37..7301fb8b 100755
--- a/examples/c/bistromathic/bistromathic.test
+++ b/examples/c/bistromathic/bistromathic.test
@@ -306,3 +306,17 @@ end of file exit exp ''
0
> ''
err: '
+
+# Check that completion when there is an error prints valid locations.
+sed -e 's/\\t/ /g' >input <<EOF
+(1++2) + 3 +\t\t
+EOF
+run -n 0 '> (1++2) + 3 +
+( - atan cos exp ln number sin sqrt
+> (1++2) + 3 +
+>
+err: 1.1: syntax error: expected - or ( or number or function or variable
before +
+err: 1.1: syntax error: expected - or ( or number or function or variable
before +
+err: 1.4: syntax error: expected - or ( or number or function or variable
before +
+err: 1.13: syntax error: expected - or ( or number or function or variable
before end of file
+'
diff --git a/examples/c/bistromathic/parse.y b/examples/c/bistromathic/parse.y
index 69c0dd12..97b60bc9 100644
--- a/examples/c/bistromathic/parse.y
+++ b/examples/c/bistromathic/parse.y
@@ -447,7 +447,7 @@ expected_tokens (const char *input,
yypstate *ps = yypstate_new ();
int status = 0;
do {
- YYLTYPE lloc;
+ YYLTYPE lloc = { 1, 1, 1, 1 };
YYSTYPE lval;
int token = yylex (&input, &lval, &lloc);
// Don't let the parse know when we reach the end of input.
--
2.27.0
- [PATCH 0/7] RFC: yypstate_clear (ATTENTION push parser users), Akim Demaille, 2020/06/28
- [PATCH 1/7] yacc.c: simplify yypull_parse, Akim Demaille, 2020/06/28
- [PATCH 2/7] yacc.c: style changes in push mode, Akim Demaille, 2020/06/28
- [PATCH 3/7] yacc.c: declare and initialize and the same time, Akim Demaille, 2020/06/28
- [PATCH 4/7] regen, Akim Demaille, 2020/06/28
- [PATCH 5/7] yacc.c: simplify initialization of push parsers, Akim Demaille, 2020/06/28
- [PATCH 6/7] bistromathic: don't display undefined locations,
Akim Demaille <=
- [PATCH 7/7] yacc.c: push: don't clear the parser state when accepting/rejecting, Akim Demaille, 2020/06/28