[antlr-interest] spaces between tokens

silverio.di at qem.it silverio.di at qem.it
Wed Nov 10 01:38:20 PST 2004






Hi,
I've a big problem.

In my grammar, how in many others, the whitespaces are skipped in lexer,
but I've some circumstances in which I need to check that not any spaces
are present between tokens.

Example :
WeekJobHour at Monday = 8

would mean assign 8 (hours) to parameter Monday of structure WeekJobHour.
I would like my lexer extract following tokens:

IDENT ATSIGN IDENT

but my problem is to check than not any WS are present between
IDENT and ATSIGN and between ATSIGN and IDENT so

WeekJobHour at Monday = 8        // is OK
WeekJobHour @Monday = 8       // is BAD
WeekJobHour@ Monday = 8       // is BAD
WeekJobHour  @ Monday = 8           // is BAD too !

I could use following lexer rule:

STRUCT_PARAMETER
      :     ('A'..'Z' | 'a..z')+
            '@'
            ('A'..'Z' | 'a..z')+
      ;

but in parser how can I extract the structure name (WeekJobHour)
and the structure parameter (Monday) form STRUCT_PARAMETER
token ?

I think a similar issue is present in C/C++ structure construct

Thank you for your suggestions about
Silverio Diquigiovanni



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list