line
        : (r+=ruleLine | z+=zoneLine | l+=linkLine | NEWLINE!)* -> $r+ $z+ $l+
        ;

:)

Ter
On Dec 22, 2010, at 2:59 PM, Christopher Hunt wrote:

> Hi there,
> 
> I'm putting the final touches to my parser of Zoneinfo (1) files and haven't 
> been able to solve the last part of the puzzle: how to group a set of AST 
> nodes such that I can ensure the order by which nodes are processed in the 
> tree grammar. The parser grammar I have should explain better:
> 
> line
>       : (ruleLine | zoneLine | linkLine | NEWLINE!)*
>       ;
> 
> ruleLine
>       : 'Rule' ruleName ruleFrom ruleTo ruleType ruleIn ruleOn ruleAt 
> ruleSave ruleLetters NEWLINE!
>       ;
> 
> zoneLine
>       : 'Zone' zoneName zoneGmtOffset zoneRules zoneFormat 
>       (zoneUntil (NEWLINE+) zoneGmtOffset zoneRules zoneFormat)* 
>       NEWLINE
>       -> 'Zone' zoneName zoneGmtOffset zoneRules zoneFormat 
>       (zoneUntil 'Zone' zoneName zoneGmtOffset zoneRules zoneFormat)* 
>       ;
> 
> linkLine
>       : 'Link' linkFrom linkTo NEWLINE!
>       ;
> 
> In essence, I need to group all of the rule lines together, and all of the 
> zone lines together so that all rules are processed by my tree grammar first, 
> then all zones are processed and finally all links are processed. This is 
> because zones reference rules and links reference zones.
> 
> Zoneinfo source files can have rules, zones and links appear in any order 
> hence my need to ensure that the AST outputs rules first then zones then 
> links.
> 
> I was thinking that referencing a previous rule as described in Terence's 
> book on p174 was the way to go, but I've not been able to make that work.
> 
> All help appreciated.
> 
> Kind regards,
> Christopher
> 
> (1) http://en.wikipedia.org/wiki/Tz_database
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to