[antlr-interest] Expressions

Peter Ashford kaffiene at xtra.co.nz
Thu Aug 5 13:56:45 PDT 2004


Sebastian Kaliszewski wrote:

>Peter Ashford wrote:
>  
>
>>Whats the recommended way to handle expressions when you can have 
>>several different kinds of expression (I'm wanting float, string and 
>>boolean expressions)?
>>    
>>
>
>Standard way is to parse everything just as expression and only in one of 
>the following compilation phase -- type determination & checking -- check if 
>the expressions are well typed (well formed).
>Types are part of semantics not syntax, and typically doing (even partial) 
>semantic checks in syntactic phase (lexer/parser) in not a good idea.
>
>rgds
>  
>
Okay, thanks for that.  My application is a simple scripting language 
which can do simple formulas.  I was thinking of having all of the 
expression rules return a VariableInfo class which stored any possible 
value and could perform the basic expression operations on it (add, 
minus, div, mult etc) - my idea being to handle the semantic issues 
within the VariableInfo class (it will check types, throw exceptions for 
mismatches, perform arithmetic options if legal)

Does that sound like a basically sane approach to take?


 
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