[antlr-interest] Re: How to parser {******} and {!{***********}!}?

lgcraymer lgc at mail1.jpl.nasa.gov
Thu Dec 18 22:25:28 PST 2003


It gets a bit messy, but you want to do something like

protected
TagBody
    ;
 		(
 		options{ 
 			generateAmbigWarnings=false;
 			}
 		:	"\r\n" {newline();}
 		|	'\r'	{newline();}
 		|	'\n'	{newline();}
 		|	~('}'|'\n'|'\r')
 		)*
    ;


TAG
    :
    '{'
     (    "!{"
          (    TagBody
          |    '}' ('!' ~('}') | ~('!')) // } but not }!}
          )*
          "}!}
     )
     |  TagBody '}'
    ;

and you'll need to set k to an appropriate value.  

--Loring

--- In antlr-interest at yahoogroups.com, "jiapu2003" <jiapu2003 at y...> 
wrote:
> I am trying to write a SRGS ABNF parser. There are two tag 
formats, 
> which I think stupid.
> 
> { ******* }
> {!{ ********* }!}
> 
> Within the tags can be anything. 
> 
> The first format is easy, I used:
> TAG	:	'{'! 
> 		(
> 		options{ 
> 			generateAmbigWarnings=false;
> 			}
> 		:	"\r\n" {newline();}
> 		|	'\r'	{newline();}
> 		|	'\n'	{newline();}
> 		|	~('}'|'\n'|'\r')
> 		)*
> 		'}'!
>                 ;
> 
> But I have no idea how to deal with the other format.


 

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