[antlr-interest] Two Conflicts..

Matthew Tedder teddemc at yahoo.com
Mon Mar 7 21:08:07 PST 2005


It would be really appreciated if someone would give
me guidance on how to resolve these two conflicts:

(1) I want someone to enter code such as: 
x = myfunc(param2,param2) * (z - 4);
y =  "You will die in the year " x ", a very sad man."

paramList
  : LPAREN (IDENT (COMMA paramList)*)? RPAREN
  ;

expr
  : NLIT
  : SLIT
  | IDENT paramList         // conflicts with "LPAREN
expr LPAREN"
                                       // because of
string concatenation
  | expr (expr)+               // for string
concatenation..
  | LPAREN expr RPAREN  // conflicts with "IDENT
paramList
  | expr TIMES expr          
  | expr DIVISION expr          
  | expr PLUS expr
  | expr MINUS expr     
  ;

(2) I want ot use "=" for assignments in a statement
context and for comparisons in a condition context.  I
currently have them as "=" for assignment and "==" for
comparison, as follows:

assignmentStmt
  : IDENT ASSIGN expr  // currently "=", as in "x =
42"
  ;

condition
  : TRUE
  | FALSE
  | LPAREN condition RPAREN
  | condition AND condition
  | condition OR condition
  | NOT condition 
  | expr EQ expr  // currently "=="; want to change to
"="
  | expr NE expr
  | expr GT expr
  | expr GE expr
  | expr LT expr
  | expr LE expr
  ;

Any advice would be appreciated greatly.  This is my
first ANTLR project....  and I have not yet compiled
anything.... due to obvious conflicts.   Thanks!

Matthew


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list