summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-24 07:40:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-24 07:40:56 -0700
commit9ff4198548519710f688fbe97e4a7267751cd840 (patch)
tree5798afe24775ebea47ad690157909eda0ba5791b
parentef185cc32a86458ca8846e3704c097d491e9d556 (diff)
downloadtxr-9ff4198548519710f688fbe97e4a7267751cd840.tar.gz
txr-9ff4198548519710f688fbe97e4a7267751cd840.tar.bz2
txr-9ff4198548519710f688fbe97e4a7267751cd840.zip
parser: improve diagnostic for unterminated exprs.
* parser.y (parse): When issuing the diagostic indicating the likely starting line of the unterminated expression, instead of mentioning that line in the diagnostic text, let's just issue the diagnostic against that line. The programmer's text editor can then jump to that line. * y.tab.c.shipped: Updated.
-rw-r--r--parser.y7
-rw-r--r--y.tab.c.shipped7
2 files changed, 10 insertions, 4 deletions
diff --git a/parser.y b/parser.y
index d15aa225..18ae9ed5 100644
--- a/parser.y
+++ b/parser.y
@@ -2121,8 +2121,11 @@ int parse(parser_t *parser, val name, enum prime_parser prim)
if (parser->errors && parser->syntax_tree == nil &&
parser->lineno != start_line)
{
- yyerrorf(parser->scanner, lit("while parsing form starting at line ~a"),
- num(start_line), nao);
+ cnum curline = parser->lineno;
+ parser->lineno = start_line;
+ yyerrorf(parser->scanner,
+ lit("while parsing expression starting on this line"), nao);
+ parser->lineno = curline;
}
return res;
diff --git a/y.tab.c.shipped b/y.tab.c.shipped
index 7e5e647e..1b27eb7a 100644
--- a/y.tab.c.shipped
+++ b/y.tab.c.shipped
@@ -7498,8 +7498,11 @@ int parse(parser_t *parser, val name, enum prime_parser prim)
if (parser->errors && parser->syntax_tree == nil &&
parser->lineno != start_line)
{
- yyerrorf(parser->scanner, lit("while parsing form starting at line ~a"),
- num(start_line), nao);
+ cnum curline = parser->lineno;
+ parser->lineno = start_line;
+ yyerrorf(parser->scanner,
+ lit("while parsing expression starting on this line"), nao);
+ parser->lineno = curline;
}
return res;