Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.Tree.toStringTree()


      // It's a set of points? => Defines a piece-wise linear membership function
      if( leaveName.equalsIgnoreCase("(") ) {
        x[childNum] = new Value(child.getChild(0), this); // Parse and add each point
        y[childNum] = new Value(child.getChild(1), this);

        if( (y[childNum].getValue() < 0) || (y[childNum].getValue() > 1) ) throw new RuntimeException("\n\tError parsing line " + child.getLine() + " character " + child.getCharPositionInLine() + ": Membership function out of range (should be between 0 and 1). Value: '" + y[childNum] + "'\n\tTree: " + child.toStringTree());

        if( debug ) Gpr.debug("Parsed point " + childNum + " x=" + x[childNum] + ", y=" + y[childNum]);
      } else throw new RuntimeException("Unknown (or unimplemented) option : " + leaveName);
    }
    return new MembershipFunctionGenericSingleton(x, y);
View Full Code Here


  private void fclTreeVariables(Tree tree) {
    Gpr.checkRootNode("VAR_OUTPUT", "VAR_INPUT", tree);
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    for( int childNum = 0; childNum < tree.getChildCount(); childNum++ ) {
      Tree child = tree.getChild(childNum);
      if( debug ) Gpr.debug("\tChild: " + child.toStringTree());
      String varName = child.getText();
      Variable variable = new Variable(varName);
      if( debug ) Gpr.debug("\tAdding variable: " + varName);

      if( varibleExists(variable.getName()) ) Gpr.debug("Warning: Variable '" + variable.getName() + "' duplicated");
View Full Code Here

    if( parseTree == null ) {
      System.err.println("Can't create FIS");
      return null;
    }

    if( debug ) Gpr.debug("Tree: " + parseTree.toStringTree());

    // Add every FunctionBlock (there may be more than one in each FCL file)
    for( int childNum = 0; childNum < parseTree.getChildCount(); childNum++ ) {
      Tree child = parseTree.getChild(childNum);
      if( debug ) Gpr.debug("Child " + childNum + ":\t" + child + "\tTree:'" + child.toStringTree() + "'");
View Full Code Here

    if( debug ) Gpr.debug("Tree: " + parseTree.toStringTree());

    // Add every FunctionBlock (there may be more than one in each FCL file)
    for( int childNum = 0; childNum < parseTree.getChildCount(); childNum++ ) {
      Tree child = parseTree.getChild(childNum);
      if( debug ) Gpr.debug("Child " + childNum + ":\t" + child + "\tTree:'" + child.toStringTree() + "'");

      // Create a new FunctionBlock
      FunctionBlock functionBlock = new FunctionBlock(fis);

      // Generate fuzzyRuleSet based on tree
View Full Code Here

        QueryParser parser = new QueryParser(tokens);
        QueryParser.query_return result = parser.query();

        Tree ast = (Tree)result.getTree();

        System.out.println( ast.toStringTree() );
        TreePrinter.printTree( (CommonTree)ast, 0 );
        Assert.assertEquals( 0, lexer.getNumberOfSyntaxErrors() );
        Assert.assertEquals( 0, parser.getNumberOfSyntaxErrors() );
    }
View Full Code Here

        QueryParser parser = new QueryParser(tokens);
        QueryParser.query_return result = parser.query();

        Tree ast = (Tree)result.getTree();

        System.out.println( ast.toStringTree() );
        TreePrinter.printTree( (CommonTree)ast, 0 );
        Assert.assertEquals( 0, lexer.getNumberOfSyntaxErrors() );
        Assert.assertEquals( 0, parser.getNumberOfSyntaxErrors() );
  
        Assert.assertEquals( "QUERY", ast.getText() );
View Full Code Here

        QueryParser parser = QueryParserUtils.createParser(tokens);
        QueryParser.query_return result = parser.query();

        Tree ast = (Tree)result.getTree();

        System.out.println( ast.toStringTree() );
        TreePrinter.printTree((CommonTree) ast, 0);
        Assert.assertEquals(0, lexer.getNumberOfSyntaxErrors());
        return parser.getNumberOfSyntaxErrors();
    }
View Full Code Here

    // rewrite the tree (temporary fix for http://www.antlr.org/jira/browse/ANTLR-427)
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    TreeRewrite s = new TreeRewrite(nodes);
    tree = (CommonTree)s.downup(tree);
     
    return tree.toStringTree();
  }
 
  /**
   *
   * @param value
View Full Code Here

      ParseListener listener = new ParseListener();
      DateParser parser = new DateParser(stream, listener);
      DateParser.parse_return parseReturn = parser.parse();
     
      Tree tree = (Tree) parseReturn.getTree();
      _logger.fine("AST: " + tree.toStringTree());
     
      // we only continue if a meaningful syntax tree has been built
      if(tree.getChildCount() > 0) {
     
        // rewrite the tree (temporary fix for http://www.antlr.org/jira/browse/ANTLR-427)
View Full Code Here

        QueryParser parser = new QueryParser(tokens);
        QueryParser.query_return result = parser.query();

        Tree ast = (Tree)result.getTree();

        System.out.println( ast.toStringTree() );
        TreePrinter.printTree( (CommonTree)ast, 0 );
        Assert.assertEquals( 0, lexer.getNumberOfSyntaxErrors() );
        Assert.assertEquals( 0, parser.getNumberOfSyntaxErrors() );
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.