[antlr-interest] Replacing a operator precedence parser

mzukowski at bco.com mzukowski at bco.com
Thu Feb 14 10:11:25 PST 2002


You would have to write a very generic set of expression rules which would
be identified by precedence level and associativity.  Then the lexer, at
runtime, would have to recognize the specific operator tokens and turn them
into generic tokens like LEVEL_5_LEFT_ASSOC.  

Antlr may not be the right tool for this.  I guess it depends on the number
of precedence levels.  Perhaps precedence could be turned into an argument
to an expression subrule, and an element of your own Token subclass.

There's food for thought here.  Do you mind sharing what this is for?  It
could be fun working out a generic expression parser that you simply provide
a table of operators, precedences and associativity to.

Monty

Hey antlr folks, check out my new "Antlr Tips" page
www.codetransform.com/tips.html


> -----Original Message-----
> From: dan.stanger at ieee.org [mailto:dan.stanger at ieee.org]
> Sent: Thursday, February 14, 2002 9:35 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Replacing a operator precedence parser
> 
> 
> I have a operator precedence parser that I would like to implement
> in antlr.  The problem is that the language allows for the definition
> of operators at run time with different left and right binding powers.
> Can I write this using antlr, and what approach should I take?
> Thank you
> Dan Stanger
> dan.stanger at ieee.org
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 
> 

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list