The below is a snippet of an ANTLR grammar which works fine.
It is intended to become a tex-parser.
If I modify rule everywhere
by uncommenting | text
, ANTLR reports a left recursion in rule escSeq
which I think is funny.
I cannot find a left recursion: either I am blind or I misunderstood what left recursion is.
Any suggestions?
afterNewline : (everywhere | par );
par : EoL {System.out.println("<PAR>");} afterNewline ;
everywhere : (Esc escSeq //| text
);
escSeq : (
EoL {System.out.println("<cmd:''>");} afterNewline |
Space {System.out.println("<cmd:' '>");} skipSpace |
name=Letter+ {System.out.println("<cmd:"+$name.text+">");} skipSpace |
Other {System.out.println("<cmd:Other>");} inLine // **** Other is too restrictive.
);
text : (Letter | Other) inLine;
skipSpace : (everywhere | (Space|EoL) {System.out.println("<SKIP>");});
inLine : (everywhere | Space | EolInLine);
EolInLine : EoL {System.out.println("<text:' '>");};
texDocument : afterNewline EOF;