Subject: bug#22241: 25.0.50; etags Ruby parser problems

From: Dmitry Gutov <[email-masked]>
Date: Mon, 1 Feb 2016 11:24:38 +0300

On 01/31/2016 09:01 PM, Eli Zaretskii wrote:

> But that was a trap, wasn't it?

Almost every feature is a trap, if one considers it long enough. :)

> What can legitimately follow the '+',
> in addition to whitespace?  (It's amazing, but among all the gazillion
> references to Ruby, I cannot easily find a formal description of its
> syntax.)

And there isn't one! Ruby is magical that way.

> According to this rare gem:
>
>    https://en.wikibooks.org/wiki/Ruby_Programming/Syntax
>
> (assuming I understand what it says), the RHS can be any literal, and
> also any constant expression, is that right?  If so, either (a) we
> recognize only '^[ \t]([A-Z][a-z0-9_])*[ \t]*=' and get potential
> false positives on the likes of
>
>     ABC == SOMETHING
>     ABC =< WHATEVER

=< is not a valid operator. You must be thinking of <=.

> etc. (are these possible?); or (b) you tell me which characters can
> potentially follow the '=' in an assignment of a constant.

Why not do it like this:

If 'ABC =' is followed by any character, except for '=' and '>', you 
record it as a tag "ABC".

>      " # % \' ( + - < ? [ {
>      0 1 2 3 4 5 6 7 8 9
>      A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
>
> And if we go the latter way, there are still multi-line expressions
> that I think are way too much.

What about them? Ideally, you'd skip over multi-line expressions, but 
you'd have to do that whether you record constants or not.