[antlr-interest] structure parameter access

Anthony Youngman Anthony.Youngman at ECA-International.com
Thu Nov 11 05:48:18 PST 2004


I think this is another example of why a filter between lexer and parser
is a good idea.

If it's white-space-aware, it can simply look for IDENT POINT IDENT, and
redefine POINT as STRUCT_SEPARATOR or something.

Cheers,
Wol 

-----Original Message-----
From: Alexey Demakov [mailto:demakov at ispras.ru] 
Sent: 09 November 2004 11:41
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] structure parameter access


From: <silverio.di at qem.it>
> I've a problem with a simple language which have
> some grammar likeness to C/C++ & Java.
> 
> I've tried to read the C & Java grammars on ANTLR
> web page but I isn't been able to uderstand how they
> solve my question.
> 
> My language say that:
> 
> a) struct_name.struct_parameter
> 
> How you can see (a) is likeness to c statement.
> My throuble is that in between struct_name and '.' I can't
> admit spaces chars and between '.' and struct_parameter
> I can't admit spaces chars too. I think this is same behaviour
> required to a C/C++ program.
> 
> But I don't understand how to obtain that starting from:
> 
> statement : label | struct_assign;
> label : LABEL EOL;
> struct_assign : IDENT POINT IDENT ASSIGN IDENT EOL;
> 
> WS : (' ' | '\t' | '\f') { $setType(Token.SKIP); };
> EOL : ("\r\n" | '\r' | '\n'   ) { newline(); };
> POINT : '.';
> IDENT : ('a'..'z')+;
> 
> Thank you very much for your suggestions...
> Silverio Diquigiovanni

Because parser doesn't know about skipped tokens the only way to
skip WS and forbid WS near POINT - is to handle
struct_name.struct_parameter
as single token in lexer.
Another idea - the only idea - is to track WS while skipping and
decorate
POINT token by flag indicating that there was WS just before or after.
You can check it in parser rule and print error message.

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com




 
Yahoo! Groups Links



 





****************************************************************************

This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.

Telephone numbers for ECA International offices are: Sydney +61 (0)2 8272 5300, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

****************************************************************************



 
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