Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.ParseTree


    callStack.pop();   
  }

  public void consumeToken(Token token) {
    if ( backtracking>0 ) return;
    ParseTree ruleNode = (ParseTree)callStack.peek();
    ParseTree elementNode = create(token);
    elementNode.hiddenTokens = this.hiddenTokens;
    this.hiddenTokens = new ArrayList();
    ruleNode.addChild(elementNode);
  }
View Full Code Here


    hiddenTokens.add(token);
  }

  public void recognitionException(RecognitionException e) {
    if ( backtracking>0 ) return;
    ParseTree ruleNode = (ParseTree)callStack.peek();
    ParseTree errorNode = create(e);
    ruleNode.addChild(errorNode);
  }
View Full Code Here

    if ( parser.getRule(startRule)==null ) {
      System.err.println("Rule "+startRule+" does not exist in "+grammarFileName);
      return;
    }
    Interpreter parseEngine = new Interpreter(parser, tokens);
    ParseTree t = parseEngine.parse(startRule);
    System.out.println(t.toStringTree());
  }
View Full Code Here

    FilteringTokenStream tokens = new FilteringTokenStream(lexEngine);
    tokens.setTokenTypeChannel(g.getTokenType("WS"), 99);
    //System.out.println("tokens="+tokens.toString());
    Interpreter parseEngine = new Interpreter(pg, tokens);
    ParseTree t = parseEngine.parse("prog");
    String result = t.toStringTree();
    String expecting =
      "(<grammar p> (prog while x { (assign i = (expr 1) ;) (assign y = (expr 3.42) ;) (assign z = (expr y) ;) } <EOF>))";
    assertEquals(expecting, result);
  }
View Full Code Here

    FilteringTokenStream tokens = new FilteringTokenStream(lexEngine);
    tokens.setTokenTypeChannel(g.getTokenType("WS"), 99);
    //System.out.println("tokens="+tokens.toString());
    Interpreter parseEngine = new Interpreter(pg, tokens);
    ParseTree t = parseEngine.parse("prog");
    String result = t.toStringTree();
    String expecting =
      "(<grammar p> (prog while x { (assign i = (expr 1) MismatchedTokenException(6!=10))))";
    assertEquals(expecting, result);
  }
View Full Code Here

    FilteringTokenStream tokens = new FilteringTokenStream(lexEngine);
    tokens.setTokenTypeChannel(g.getTokenType("WS"), 99);
    //System.out.println("tokens="+tokens.toString());
    Interpreter parseEngine = new Interpreter(pg, tokens);
    ParseTree t = parseEngine.parse("prog");
    String result = t.toStringTree();
    String expecting =
      "(<grammar p> (prog while x { (assign i = (expr MismatchedSetException(10!={5,6,7})))))";
    assertEquals(expecting, result);
  }
View Full Code Here

    FilteringTokenStream tokens = new FilteringTokenStream(lexEngine);
    tokens.setTokenTypeChannel(g.getTokenType("WS"), 99);
    //System.out.println("tokens="+tokens.toString());
    Interpreter parseEngine = new Interpreter(pg, tokens);
    ParseTree t = parseEngine.parse("prog");
    String result = t.toStringTree();
    String expecting =
      "(<grammar p> (prog while x { (assign i = (expr NoViableAltException(10@[4:1: expr : ( INT | FLOAT | ID );])))))";
    assertEquals(expecting, result);
  }
View Full Code Here

    if ( parser.getRule(startRule)==null ) {
      System.err.println("Rule "+startRule+" does not exist in "+grammarFileName);
      return;
    }
    Interpreter parseEngine = new Interpreter(parser, tokens);
    ParseTree t = parseEngine.parse(startRule);
    System.out.println(t.toStringTree());
  }
View Full Code Here

    CommonTokenStream tokens = new CommonTokenStream(lexEngine);
    tokens.setTokenTypeChannel(g.getTokenType("WS"), 99);
    //System.out.println("tokens="+tokens.toString());
    Interpreter parseEngine = new Interpreter(pg, tokens);
    ParseTree t = parseEngine.parse("prog");
    String result = t.toStringTree();
    String expecting =
      "(<grammar p> (prog while x { (assign i = (expr 1) ;) (assign y = (expr 3.42) ;) (assign z = (expr y) ;) } <EOF>))";
    assertEquals(expecting, result);
  }
View Full Code Here

    CommonTokenStream tokens = new CommonTokenStream(lexEngine);
    tokens.setTokenTypeChannel(g.getTokenType("WS"), 99);
    //System.out.println("tokens="+tokens.toString());
    Interpreter parseEngine = new Interpreter(pg, tokens);
    ParseTree t = parseEngine.parse("prog");
    String result = t.toStringTree();
    String expecting =
      "(<grammar p> (prog while x { (assign i = (expr 1) MismatchedTokenException(5!=9))))";
    assertEquals(expecting, result);
  }
View Full Code Here

TOP

Related Classes of org.antlr.runtime.tree.ParseTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.