[antlr-interest] Predicate Syntax Problem
Bill Venners
bv-svp at artima.com
Thu Jan 11 22:34:27 PST 2007
Hello,
I am not sure how to add a predicate to one element of an OR
expression in ANLTR 3.
passedDecl
: 'not-null'? ('byte' | 'short' | 'int' | 'long' | 'boolean'
| 'float' | 'double'
| 'char' | ID_UP )^ { isTypeName($ID_UP.getText()) }?
ID_DOWN { isVarName($ID_DOWN.getText()) }?
;
This is apparently valid grammar syntax, but the $ID_UP doesn't work.
I get:
com/artima/view/ViewParser.java:497: cannot find symbol
symbol : variable $ID_UP
location: class com.artima.view.ViewParser
if ( !( isTypeName($ID_UP.getText()) ) ) {
I am unable to find any help in the documentation I can find. Can
someone help me understand what I should do here? What I'd like to
accomplish is to kill the parse if the ID_UP variable returns false
when passed to isTypeName().
Thanks.
Bill
----
Bill Venners
President
Artima, Inc.
http://www.artima.com
P.S. I also tried the following, which are apparently not valid ANTLR
3 grammar syntax:
passedDecl
: 'not-null'? ('byte' | 'short' | 'int' | 'long' | 'boolean'
| 'float' | 'double'
| 'char' | ID_UP { isTypeName($ID_UP.getText()) }?)^
ID_DOWN { isVarName($ID_DOWN.getText()) }?
;
passedDecl
: 'not-null'? ('byte' | 'short' | 'int' | 'long' | 'boolean'
| 'float' | 'double'
| 'char' | ID_UP ){ isTypeName($ID_UP.getText()) }?^
ID_DOWN { isVarName($ID_DOWN.getText()) }?
;
More information about the antlr-interest
mailing list