[antlr-interest] Syntatic predicates...
Terence Parr
parrt at cs.usfca.edu
Wed May 19 12:42:12 PDT 2004
On May 18, 2004, at 11:23 AM, Mark Lentczner wrote:
>> Actually, this is a problem with the language as it is ambiguous.
> Well, where "ambiguous" here means considering only finite k
> lookahead...
Howdy :)
I think I mean language ambig which has no notion of k. :)
>> I cite C++ expr vs decl which can only be solved with arbitrary
>> lookahead,
> So, yes, it isn't "ambiguous" in the larger sense (sequence of tokens
> in C++ can only mean one thing.)
Well, i think Bjarne disagrees:
From Ellis and Stroustrup (Annotated C++ Ref.) “There is an ambiguity
in the grammar involving expression-statements and declarations... The
general cases cannot be resolved without backtracking... In particular,
the lookahead needed to disambiguate this case is not limited.”
T(*a)->m=7; //expression-statement
T(*a)(int); //declaration
“In a parser with backtracking the disambiguating rule can be stated
very simply: [1] If it looks likeadeclaration, it is; otherwise [2] if
it looks likeanexpression, it is; otherwise” [3] it is a syntax error.”
ANTLR notation for Stroustrup solution:
stat: (declaration)=>declaration | expression ;
Ter
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing
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