[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Side-effect of change to scan-code.l
From: |
Alex Rozenman |
Subject: |
Re: Side-effect of change to scan-code.l |
Date: |
Tue, 4 Jan 2011 18:15:45 +0200 |
Hi Paul,
Thanks for your mail. I reproduced the issue.
According to a change done by Akim Demaille 2009-05-04:
2009-05-04 Akim Demaille <address@hidden>
> identifiers: dashes are letters.
Dashes can now start identifiers (symbols and directives).
identifiers (and therefore, named references) may start with dashes. Also,
when I tried to apply
your suggestion, I noticed some regression tests failures (016, 040, 236).
I assume that we should keep this functionality. I would suggest the
following minimalistic patch:
diff --git a/src/scan-code.l b/src/scan-code.l
index a5f570d..76e050f 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -526,7 +526,10 @@ parse_ref (char *cp, symbol_list *rule, int
rule_length,
{
long int num = strtol (cp, &cp, 10);
if (1 - INT_MAX + rule_length <= num && num <= rule_length)
- return num;
+ {
+ ref_tail_fields = cp;
+ return num;
+ }
else
{
complain_at (text_loc, _("integer out of range: %s"),
If you have no objections, I will push it.
Alex
On Tue, Jan 4, 2011 at 5:11 AM, Paul Hilfinger <address@hidden>wrote:
>
> I have found a side-effect of commit
> b9f1d9a47a49c40e8f0a5006b492daba53f25b20,
> (which introduced named symbol references). In the current git head
> version, a reference such as
>
> foo : bar { $-1.p(); }
>
> is treated instead as
>
> foo : bar { $-1(); }
>
> I'm guessing this is because of the lexical syntax given for a
> reference:
>
> "$"("<"{tag}">")?{ref}
>
> where 'ref' is defined
>
> letter [-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
> id {letter}({letter}|[0-9])*
> ref -?[0-9]+|{id}|"["{id}"]"|"$"
>
> As you can see, this matches $-1.p, but only matches the '$1' part of
> $1.p, so that $1.p() gets handled as I had expected.
>
> This is minor, and easily worked around with ($-1).p(), but it is
> inconsistent with previous behavior.
>
> It seems a bit annoying to fix (since it is not clear what an identifier
> ought to be), but perhaps
>
> letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
> id {letter}({letter}|[-0-9])*
> ref -?[0-9]+|{id}|"["{id}"]"|"$"
>
> ?
>
> Paul Hilfinger
>
--
Best regards,
Alex Rozenman (address@hidden).