How to run source code?

Feb 4, 2009 at 10:15 PM
Can somebody confirm to me that this is standard procedure to run program from source code. The thing I'm woried about about is calling AnalizeCode. Is it required? Without it I get null point exception, and I see that dispatcher is not set that dispatcher is not set in runtime object. It's probably a bit silly to ask, but what exactly AnalyzeCode for? 


var grammar = new LanguageGrammar();
var compiler = new LanguageCompiler(grammar);
var tree = (ProgramNode)compiler.Parse(@"a = 150 + 28");

compiler.AnalyzeCode(tree, new CompilerContext(compiler));

tree.Scope = new Scope(tree, null);
tree.Evaluate(new EvaluationContext(new LanguageRuntime(), tree));
Coordinator
Feb 4, 2009 at 11:09 PM
yes, that's true, you should call AnalyzeCode before you execute it. Usually the middle phase of compiler processing is called code analysis, so here's the name. It actually does all "hooking" inside nodes - connect callers to target functions or operator implementations, allocates and binds variables, etc. All Interpreter part is very sketchy for now, draft, proof of concept rather than real code. It certainly needs more work, and I hope to improve it in the future... I hope...
Roman
Feb 5, 2009 at 8:12 PM
Thanks for the info.

Sergej Andrejev


On Thu, Feb 5, 2009 at 1:10 AM, rivantsov <notifications@codeplex.com> wrote:

From: rivantsov

yes, that's true, you should call AnalyzeCode before you execute it. Usually the middle phase of compiler processing is called code analysis, so here's the name. It actually does all "hooking" inside nodes - connect callers to target functions or operator implementations, allocates and binds variables, etc. All Interpreter part is very sketchy for now, draft, proof of concept rather than real code. It certainly needs more work, and I hope to improve it in the future... I hope...
Roman

Read the full discussion online.

To add a post to this discussion, reply to this email (irony@discussions.codeplex.com)

To start a new discussion for this project, email irony@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com