[antlr-interest] forgiving parser for expressions without a terminal
Manaloto-Raymond
Manaloto-Raymond at norc.org
Thu Feb 3 14:08:58 PST 2005
I am trying to work with the Java grammar that is in the examples from
the download.
I was wondering if anybody had any suggestions on having ANTLR be more
forgiving for the expression part in the statement rule. Below is the
block I am talking about:
statement
// A list of statements in curly braces -- start a new
scope!
: compoundStatement
// declarations are ambiguous with "ID DOT" relative to
expression
// statements. Must backtrack to be sure. Could use a
semantic
// predicate to test symbol table to see what the type was
coming
// up, but that's pretty hard without a symbol table ;)
| (declaration)=> declaration SEMI!
// An expression statement. This could be a method call,
// assignment statement, or any other expression evaluated
for
// side-effects.
| expression SEMI!
I want the expression alternative to not need the 'SEMI' terminal as I
am trying to build a very user friendly pseudo language where user's can
be allowed to "forget" to type in the terminating 'SEMI' (Like in
Javascript). Right now, if I don't require the terminating 'SEMI' I get
nondeterminism errors.
Any hints or ideas?
Any help would be greatly appreciated.
Raymond Manaloto
NORC
55 East Monroe Street Suite 1840
Chicago, IL 60603
Software Engineer
Work: (312) 759.5061
Fax: (312) 759.4200
Mobile: (773) 814.9666
manaloto-raymond at norc.org
AIM: sortakool
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050203/9348eaf4/attachment.html
More information about the antlr-interest
mailing list