public void VisitLine(String line) { Core interp_visitor = new Core(); PrintVisitor print_visitor = new PrintVisitor(interp_visitor); ANTLRStringStream string_stream = new ANTLRStringStream(line); spinachLexer lexer = new spinachLexer(string_stream); CommonTokenStream tokens = new CommonTokenStream(lexer); spinachParser parser = new Test_Core(tokens, ""); try { spinachParser.program_return program = parser.program(); //h= (l+j)*h*l+l-h; if (strBuilder.ToString() == "") { List<Element> elements = program.ret; ///-- call core function. to pass list of element. for (int i = 0; i < elements.Count; i++) { Element curr = elements[i]; curr.Accept(print_visitor); curr.Accept(interp_visitor);//PlotReceiver } } else { Onerror(101, strBuilder.ToString()); } } catch (RecognitionException e) { Onerror(102, e.Message); } }
public static void Main(string[] args) { PlotReceiver plot = new PlotReceiver(); Core obj = new Core(plot); executor obj1 = new executor(plot); obj1.errEvent += new executor.err(error); obj1.VisitLine("ubPlot(1,a,\"abc\",1D);vec[i]=i + 2;mat[i][j] = i + 2;"); }
public executor(PlotReceiver plot) { coreObject = new Core(plot); frontEnd = new exec(); frontEnd.error_ +=new exec.errorreport(Onerror); frontEnd.astEvent += new Spinach.exec.ast(AST); coreObject.errorcore_ +=new Core.errorcoremsg(Onerror); coreObject.rescore_ += new Core.resultcore(coreObject_rescore_); }
public executor() { coreObject = new Core(); frontEnd = new exec(); this.setFrontEndToCore(); frontEnd.error_ +=new exec.errorreport(Onerror); frontEnd.astEvent += new Spinach.exec.ast(AST); coreObject.errorcore_ +=new Core.errorcoremsg(Onerror); coreObject.rescore_ += new Core.resultcore(coreObject_rescore_); }
public PrintVisitor(Core interp) { this.interp = interp; }