What's the best way to process an AST?

Feb 1, 2008 at 11:57 PM
Do you have a sample Expression machine? I guess that would answer my question.

It kinda looks like I want to create a NodeCreator for a BinOp and then have that AstNode add custom Eval/etc methods. How did you think everyone was going to do that part? I'm just guessing you had a better idea than me :)

Andrew
Coordinator
Feb 7, 2008 at 4:08 AM
No, I don't have anything yet to use as example (Expr machine). Yes, that's the way it will be, with AstNode.Eval method and so on, they are not there yet. They will be - pls dont think that I planned that everybody will be doing this on his own - there will be AST tree iterators and default evaluator. I will try to put some empty virtual methods (and classes for execution context, scope etc) in next code drop (in a week or so); for now - try to cook something yourself along this direction.
thanks
Roman
Feb 7, 2008 at 7:08 AM
Ah good,
I got something going for the Expression grammar. There's a lot of code to figure out "where I am" in the AST in my BinOp.NodeCreator.

With a bigger grammer having NodeCreators on simpler NonTerminals is a little easier to read. Grabbing the pieces and parts of the grammar is still cumbersome at best.
On my SQL grammar I've been grabing the info I need by "AST XPath". Like so...
variablesize = GetInfo("datatype.data_size.Number", children);}

The AstNode / Token / GenericNode hierarchy makes life difficult trying to find the information in the tree. (Hint, hint :) )

I've gotten the compiler / my grammar working with case-insensitivity. I'd be happy to work on a more permanent fix if you want some help on that.

Right, back to breaking things....
Andrew
Coordinator
Feb 7, 2008 at 5:00 PM
hi
I'm really interested in what you're doing - SQL grammar? SQL is a very good case to add to sample grammars so let's work on this.
Case-insensitivity - there's a flag for this in Grammar, did you use that?
Send me what you have, I will try to help as much as I can. I will try to make Eval/Visit methods for AST tree in next source drop.
Roman