[antlr-interest] Enhancement request for identifying imaginary tokens

Hardy, Stephen Stephen.Hardy at digi.com
Thu Dec 13 14:47:08 PST 2007


Maybe I missed something, but it would be nice if there was an option to
automatically "identify" all imaginary tokens.  Currently, this requires
explicit identification as per the following example:

struct_declarator
    : declarator (':' constant_expression)?	
        -> ^(STRUCT_DECLARATOR[$start] declarator constant_expression?)
    | ':' constant_expression			
        -> ^(STRUCT_DECLARATOR_ANON_BITFIELD[$start]
constant_expression)
    ;


Admittedly, it's not all that difficult to put the
MY_IMAGINARY_TOKEN[$start] construct everywhere in the tree writing
part, but it does make the code less readable.  Having an option to do
this by default would be very handy when debugging tree walkers.
Something like

options {
  IdentifyImaginaryTokensWithStart = true;
}

Regards,
SJH



More information about the antlr-interest mailing list