[antlr-interest] Records

Phil Ritchie endigitalmind at yahoo.co.uk
Sun Jul 16 22:48:27 PDT 2006


----- Original Message ----
From: Terence Parr <parrt at cs.usfca.edu>
To: Antlr Interest <antlr-interest at antlr.org>
Sent: Sunday, 16 July, 2006 11:05:28 PM
Subject: Re: [antlr-interest] Records


On Jul 16, 2006, at 2:53 PM, Phil Ritchie wrote:

> [Using ANTLRWorks 1.0ea11]
>
> I'm creating a grammar to parse a record oriented file. (I know,  
> there are more appropriate ways.) Everything works just dandy for  
> the first record but then parsing stops. I have defined my start  
> rule as:
>
> file    :    record+
>         ;
>
> The whole definition of record appears to be fine so I'm stumped.

Whitespace issue?  Returning newline as a real token on the main  
"channel"?

Ter

No, I wasn't. Maybe I should. Changed my specification of file to:
file    :    (record '\n')+
        ;

but it's now clashing with the individual record fields which can be multiline, eg:
field1: some text on 
multiple lines
field2: more multiline
text
field1: multiline text for 
record 2 field1
field2: field2, record2
text

I've defined field1 and field2 as reserved words and for the single record parsing it works fine with newline on channel 99.

Phil.


More information about the antlr-interest mailing list