[antlr-interest] Re: Predicate question
Brad Schick
schick at robotbattle.com
Mon May 3 12:40:05 PDT 2004
Thanks for the feedback.
>>What is the purpose of first matching LA(1) to this broad
>>tokenset?
>
>It's probably due to the fact that the rule matches nothing
>as a result ANTLR first checks the follow set of the rule and
>then attempts the predicate only if the followset is not matched.
Yes, this is definitely because of the empty match (but it looks
like the followset is checked for a match rather than a non-match).
This leads me to ask; why is the code generated for the lookahead
test of a syntactic predicate different when the rule matches
nothing?
>It's maybe something personal of me, but rules that match
>nothing when using a recursive descent parser are plain ugly ;)
I'd like to get rid of it, but no other solutions have occurred to
me. The grammar is for an existing procedural language that has one
statement per line, each terminated with a newline. Except for the
special case where that last statement of a function can be
terminated by the function's closing '}'. Like "stmnt2" below:
func{
stmnt1
stmnt2}
The '}' has dual purposes: Terminate the last statement and close
the function. So is there a way to write a non-ugly grammar for an
ugly language?
Thanks,
Brad
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list