[antlr-interest] Re: Local lookahead depth

John D. Mitchell johnm-antlr at non.net
Mon Nov 10 10:47:44 PST 2003


>>>>> "Oliver" == Oliver Zeigermann <oliver at zeigermann.de> writes:
[...]

> It describes a language with two words: 1.) SHORTWORD: exactly 1000 '*'
> followed by a single '#' 2.) LONGWORD: exactly 10000 '*' followed by a
> single '#'

> While the are certainly other grammars that describe this language, this
> one seems to be the most natural, but does not work, because semantic
> predicates (like {cnt < 1000}?) rely on semantic actions ({ cnt++; }, {
> cnt = 0; }).

Do you really *need* to do that strictly in the parser?  Why not just suck
down a simpler language in the parser -- which recognizes any number of
stars followed by a # -- and then do a more refined semantic check in a
later stage.  That would make for a much cleaner solution.

Take care,
	John

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list