[antlr-interest] Re: Allowing Space characters in string lite rals under certain circumstances

mzukowski at yci.com mzukowski at yci.com
Wed Jan 14 14:32:44 PST 2004


This is the best solution.  In English that predicate says if you see any
number of spaces followed by a STRCHAR then go ahead and match the spaces
and STRCHARs.  You may get a warning from ANTLR that the syntactic predicate
is superfluous but in fact it is not and this should work.  Inspect the
generated code to convince yourself that it is right (that's the best way to
learn how antlr really works too.)

Monty

-----Original Message-----
From: Lubos Vnuk [mailto:lubos.vnuk at rts.at] 
Sent: Wednesday, January 14, 2004 12:09 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: Allowing Space characters in string literals
under certain circumstances

...or maybe: 

STRING_LITERAL : (STRCHAR)+ ( ((' ')+ STRCHAR)=> (' ')+ (STRCHAR)+ )*
;

could do the trick.

HTH,
Lubos.


--- In antlr-interest at yahoogroups.com, "Lubos Vnuk" <lubos.vnuk at r...> 
wrote:
> Hi Ron,
> 
> How about:
> 
> STRING_LITERAL : (STRCHAR)+ ( (' ')+ (STRCHAR)+ )*
> ;
> 
> HTH,
> Lubos.
> 
> --- In antlr-interest at yahoogroups.com, "Ron Denis" <rdenisus at y...> 
> wrote:
> > I need the ability to allow space characters inside a string 
> literal (not at
> > the beginning or end of the literal, only internally).  But I 
need 
> to ignore
> > the space as simply whitespace otherwise.
> > 
> >  
> > 
> > So, I need to be able to parse:
> > 
> >  
> > 
> > = Ron Denis
> > 
> >  
> > 
> > But the space before Ron and any spaces after Denis are ignored 
but 
> the
> > space between Ron and Denis is part of the string literal.  So 
the 
> token
> > will be "Ron Denis".
> > 
> >  
> > 
> > Is this possible?
> > 
> >  
> > 
> > Ron Denis
> > 
> > Systems Architect
> > 
> > FEI.Com


 

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/ 


 

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