This project has moved and is read-only. For the latest updates, please go here.

What's the best way to process an AST?

Feb 2, 2008 at 12:57 AM
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 :)

Feb 7, 2008 at 5: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.
Feb 7, 2008 at 8: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....
Feb 7, 2008 at 6:00 PM
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.