public RPN Compute() { //We bind late because otherwise there is no way that someone can attach into //either of the below channels! Data.Logger.Bind(Channels.Debug, Logger); Data.Logger.Bind(Channels.Output, Output); Tokens = _tokenizer.Tokenize(); Data.Polish = _shunt.ShuntYard(this.Tokens); //Generate an Abstract Syntax Tree var logger = Data.Logger; AST ast = new AST(this); ast.Output += Output; ast.Logger += Logger; ast.Generate(this.Data.Polish); logger.Log(Channels.Debug, "AST RPN : " + ast.Root.ToPostFix().Print()); //Simplify the Abstract Syntax Tree //This can take quite a lot of time ast.Simplify(); ast.MetaFunctions(); this.Data.Polish = ast.Root.ToPostFix().ToArray(); this.Data.SimplifiedEquation = ast.Root.ToInfix(this.Data); logger.Log(Channels.Debug, ""); logger.Log(Channels.Debug, "AST Simplified RPN : " + Data.Polish.Print()); logger.Log(Channels.Debug, "AST Simplified Infix : " + Data.SimplifiedEquation); logger.Log(Channels.Debug, ast.Root.Print()); //TODO: We should flush the Logger here return(this); }
Generate( AST.PropertyDecl nodeProp ) { nodeProp.Generate(this); }