Spinach.Program.VisitLine C# (CSharp) Method

VisitLine() public method

public VisitLine ( String line ) : void
line String
return void
        public void VisitLine(String line)
        {
            ANTLRStringStream string_stream = new ANTLRStringStream(line);
            spinachLexer lexer = new spinachLexer(string_stream);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            spinachParser parser = new Program(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.
                    Onoutput(elements);

                    for (int i = 0; i < elements.Count; i++)
                    {
                        Element curr = elements[i];
                        //curr.Accept(print_visitor);
                        //curr.Accept(interp_visitor);
                    }
                }
                else
                {
                    Onerror(101, strBuilder.ToString());
                }
            }
            catch (RecognitionException e)
            {
                Onerror(102, e.Message);
            }
        }

Usage Example

Example #1
0
 public void Visitline(string args)
 {
     CommonTokenStream str = new CommonTokenStream();
     //We need the syntax for the core object
     Program myprog = new Program(str);
     myprog.error += new Program.errorreport(Onerror);
     myprog.AstEvent += new Program.AstReport(Onoutput);
     myprog.VisitLine(args);
 }