Example #1
0
      public void VisitLine(String line){
         ANTLRStringStream string_stream = new ANTLRStringStream(line);
         InterpLexer lexer = new InterpLexer(string_stream);
         CommonTokenStream tokens = new CommonTokenStream(lexer);			
         InterpParser parser = new InterpParser(tokens);
         try {
            InterpParser.program_return program = parser.program();
            List<Element> elements = program.ret;
            for(int i = 0; i < elements.Count; i++){
              Element curr = elements[i];
              //curr.Accept(print_visitor);
              //curr.Accept(interp_visitor);
            }
          } catch (RecognitionException e)  {
            Console.WriteLine(e.Message);
          } 

      }
Example #2
0
    //----< parsing the text >------------------------------
    public void VisitLine()
    {
        int i = 0;
        try
        {
            ANTLRStringStream string_stream = new ANTLRStringStream(line);
            InterpLexer lexer = new InterpLexer(string_stream);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            InterpParser parser = new InterpParser(tokens);

            setVisitorDelegate(dele);
            InterpParser.program_return program = parser.program();
            List<Element> elements = program.ret;
            for (i = 0; i < elements.Count; i++)
            {
                Element curr = elements[i];
                curr.Accept(print_visitor);
                curr.Accept(interp_visitor);
            }
            dele("END");
        }
        catch (RecognitionException e)
        {
            Console.WriteLine(e.Message);
            dele("Syntax error in source code.\n");
            dele(e.Message);
            dele("END");
        }
    }