Everything about my daily life as a programmer/Electrical Engineer!

IronPython Parser AST walker

I just thought I would post an example of an IronPython 1.1 parser for AST. You can override tons of methods on the ASTWalker class to get the job done.

Parser p=Parser.FromString(new IronPython.Runtime.SystemState(),new CompilerContext(),"a=5+10");
Statement e=p.ParseSingleStatement();
e.Walk(new ExpressionWalker());


public class ExpressionWalker : IronPython.Compiler.Ast.AstWalker
{
public override void PostWalk(NameExpression node)
{
base.PostWalk(node);
}
}

No comments: