[antlr-interest] Allowing Space characters in string literals under certain circumstances

Ron Denis rdenisus at yahoo.com
Wed Jan 14 10:14:23 PST 2004


Thanks Matt.

That is one of the approaches that I have been looking into but I am
screwing something up.  In my first meager attempt, this is what I have:

STRING_LITERAL
	:	( STRCHAR ) ( ( STRCHAR | ' ' )* ( STRCHAR ) ) *
	;

protected 
STRCHAR
	:	( 'a'..'z'
        | 'A'..'Z'
        | '0'..'9'
        | '!'..'$'
        | '\''..'/'
        | ';'
        | '?'..'@'
        | '['..'_'
        | '{'
        | '}'..'~'
        )
	;

But I get a non-determinism error message.  If instead I change the
STRING_LITERAL to:

STRING_LITERAL
	:	( STRCHAR ) ( STRCHAR | ' ' )* 
	;

This appears to work but it allows spaces at the end of the literals.

Ron

-----Original Message-----
From: Matt Benson [mailto:gudnabrsam at yahoo.com] 
Sent: Wednesday, January 14, 2004 12:29 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] Allowing Space characters in string literals
under certain circumstances

IIRC, the usual advice here is to switch lexers or
lexer states...

-Matt

--- Ron Denis <rdenisus at yahoo.com> 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
> 
>  
> 
> > BEGIN:VCARD
> VERSION:2.1
> N:Denis;Ron
> FN:rdenisus at yahoo.com
> ORG:Independant Consultant
> TITLE:Systems Architect
> TEL;WORK;VOICE:(410) 712-0590 x26
> TEL;HOME;VOICE:(717) 235-0415
> TEL;CELL;VOICE:(717) 515-5769
> EMAIL;PREF;INTERNET:rdenisus at yahoo.com
> REV:20031215T193956Z
> END:VCARD
> 


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

 

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