[antlr-interest] Re: Local lookahead depth

Joe Comuzzi jcomuzzi at novell.com
Mon Nov 10 12:18:05 PST 2003


At the risk of jumping into an on-going conversation. I'd like to join
the argument FOR some sematic predicates in the presence of
backtracking. 

It's certainly the case that you can solve any case which seems to need
this by using a tree-walk. I claim you do give something up by solving
it this way. One of the great advantages of LL parsing (and ANTLR) is
that it's easy to write good error messages. Now, maybe I'm not doing it
right - but I find when I have to check semantics in a tree-walk pass,
the quality of the errors revert to the kind of contextless non-sense
one typically sees in YACC and LR parsers. So, for me, the justification
of doing semantic checks in the parser is the quality of error messages
- and this has been an important enough consideration to occasionally
use code in init actions to control the parse...

My 2 cents - YMMV

Joe C. 

>>> oliver at zeigermann.de 11/10/2003 2:54:07 PM >>>
John D. Mitchell wrote:
>>>>>>"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.

John, it seems we again have a communication problem. It is just an 
example to illustrate something. I do not have a practical problem like

this. This is a *theoretical* discussion. I am talking *theory* all the

time :)

Oliver



 

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



 

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




More information about the antlr-interest mailing list