[antlr-interest] Re: handling line-based data with stanzas

Chris Black cblack0 at yahoo.com
Wed May 12 09:02:49 PDT 2004


--- In antlr-interest at yahoogroups.com, "Chris Black" <cblack0 at y...> wrote:
> I have been writing a few grammars for a few different file formats
> that are line-based but also are organized into stanzas.
> Most of these look like:
> ---
> header,stuff ican,parse,easily
> 
> start stanzatypefoo
> column header,column header,column header
> value,value,value
> start stanzatypebar
> column header,column header,column header
> value,value,value
> ---
> 

I am still playing with AST construction for this type of data, one
error I am running into is having rules like:
---
fileHeader: progHeader^ sessionHeader NEWLINE!
	{ #fileHeader = #([FILEHEADER,"file header"], #fileHeader); }
	; 

progHeader: FIELD DELIM! FIELD NEWLINE!
	FIELD DELIM! FIELD NEWLINE!
	FIELD DELIM! FIELD DELIM! FIELD NEWLINE! NEWLINE 
	{ System.err.println("progHeader matched"); } ;
---
where I am trying to get the tree or tokens output by a subrule to be
placed one level up. I only seem to be able to use the suffix ^ on
tokens, not subrules. Is there any way to accomplish what I am trying
to do?
Also, if anyone has a nice best practice for handling
stanza/line-based data I'd love to hear it.

Thanks,
Chris




 
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