[antlr-interest] detecting transitions in stanza-based files

Bryan Ewbank ewbank at gmail.com
Tue May 10 10:05:26 PDT 2005


Oh, I see.  The original example was different, so I went the wrong way ;-(.

Yes, you should be able to do that.  Easiest is something like this (a
syntactic predicate that forces matches of shortLine to be processed
by shortLine).

   line : ( shortLine ) => shortLine
        | longLine
        ;

> line: FIELD DELIM FIELD DELIM FIELD NEWLINE => shortLine
>      | FIELD DELIM FIELD DELIM FIELD DELIM FIELD => longLine

>>shortLine: FIELD DELIM FIELD DELIM FIELD NEWLINE
>>longLine: FIELD DELIM FIELD (DELIM FIELD)+ NEWLINE

should be
  longLine: FIELD DELIM FIELD DELIM FIELD (DELIM FIELD)+ NEWLINE


More information about the antlr-interest mailing list