bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improve error messages for `$' or `@' followed by `.' or `-'.


From: Joel E. Denny
Subject: Re: Improve error messages for `$' or `@' followed by `.' or `-'.
Date: Sun, 9 Jan 2011 18:24:44 -0500 (EST)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

Hi Alex,

On Sun, 9 Jan 2011, Alex Rozenman wrote:

> If this is a syntax error, we'd prefer to that "$.field" will not be parsed
> as a {ref} at all.
> It would imply, for example that references without bracketing will not
> start with dots.
> 
> For example:
> letter    [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
> c_letter [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
> id        -*(-|{letter}({letter}|[-0-9])*)
> ref      -?[0-9]+|{c_letter}({letter}|[0-9])*|"["{id}"]"|"$"

I would usually agree that a syntax error should be handled in the 
syntactic specification.  However...

> Anyway, if we want to keep "possibly meant" error messages in this case,
> your local solution is fine.

Exactly.  We have this theme for named references such that, after a $ or 
@, Bison recognizes anything that could be a symbol name so it can provide 
helpful warnings and errors for the user.  This syntax error falls in the 
domain of that theme.  Thus, to be consistently helpful to the user, I 
think Bison's handling of that syntax error should follow that theme.

> So no objections from my side.

Thanks.

I folded in the following correction and then pushed that patch to master 
and branch-2.5.

diff --git a/src/scan-code.l b/src/scan-code.l
index 06c5a28..3dd1044 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -628,7 +628,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
             sym_loc.end = sym_loc.start;
             const char *format =
               _("syntax error after `%c', expecting integer, letter,"
-                " `_', or `['");
+                " `_', `[', or `$'");
             complain_at_indent (sym_loc, &indent, format, dollar_or_at);
           }
         else if (midrule_rhs_index)
diff --git a/tests/named-refs.at b/tests/named-refs.at
index d6c8ad3..74549c6 100644
--- a/tests/named-refs.at
+++ b/tests/named-refs.at
@@ -579,14 +579,14 @@ start:
 ]])
 AT_BISON_CHECK([[test.y]], [[1]], [],
 [[test.y:4.12-18: invalid reference: `$.field'
-test.y:4.13:        syntax error after `$', expecting integer, letter, `_', or 
`@<:@'
+test.y:4.13:        syntax error after `$', expecting integer, letter, `_', 
`@<:@', or `$'
 test.y:4.3-8:       possibly meant: $[.field] at $1
 test.y:5.12-18: invalid reference: address@hidden'
-test.y:5.13:        syntax error after `@', expecting integer, letter, `_', or 
`@<:@'
+test.y:5.13:        syntax error after `@', expecting integer, letter, `_', 
`@<:@', or `$'
 test.y:5.3-8:       possibly meant: @[-field] at $1
 test.y:6.12-18: invalid reference: address@hidden'
-test.y:6.13:        syntax error after `@', expecting integer, letter, `_', or 
`@<:@'
+test.y:6.13:        syntax error after `@', expecting integer, letter, `_', 
`@<:@', or `$'
 test.y:7.12-18: invalid reference: `$-field'
-test.y:7.13:        syntax error after `$', expecting integer, letter, `_', or 
`@<:@'
+test.y:7.13:        syntax error after `$', expecting integer, letter, `_', 
`@<:@', or `$'
 ]])
 AT_CLEANUP



reply via email to

[Prev in Thread] Current Thread [Next in Thread]