Package xtc.tree

Examples of xtc.tree.Node


   * @throws IOException Signals an I/O error.
   */
  private Result pInfixPatternTail(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyOption1;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = pId(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$1 = yyResult.semanticValue();

      yyOption1  = yyResult.index;

      yyResult = pN(yyOption1);
      yyError  = yyResult.select(yyError, yyOption1);
      if (yyResult.hasValue()) {

        yyOption1  = yyResult.index;
      }

      yyResult = pSimplePattern(yyOption1);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        Node v$g$2 = yyResult.semanticValue();

        yyValue = GNode.create("InfixPatternTail", v$g$1, v$g$2);
        yyValue.setLocation(location(yyStart));

        return yyResult.createValue(yyValue, yyError);
View Full Code Here


  private Result pSimplePattern$1(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyBase;
    int        yyOption1;
    String     yyOpValue1;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = pXmlPattern(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$1 = yyResult.semanticValue();

      yyValue = GNode.create("SimpleXmlPattern", v$g$1);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 2.

    yyResult = pkey(yyStart);
    if (yyResult.hasValue("_")) {
      String v$g$2 = "_";

      yyOption1  = yyResult.index;
      yyOpValue1 = null;

      yyBase   = yyOption1;
      yyResult = pop(yyBase);
      if (yyResult.hasValue("*")) {
        String v$el$1 = "*";

        yyOption1  = yyResult.index;
        yyOpValue1 = v$el$1;
      } else {
        yyError = yyError.select("'*' expected", yyBase);
      }
      { // Start scope for v$g$3.
        String v$g$3 = yyOpValue1;

        yyValue = GNode.create("SimpleWildcardPattern", v$g$2, v$g$3);
        yyValue.setLocation(location(yyStart));

        return new SemanticValue(yyValue, yyOption1, yyError);
      } // End scope for v$g$3.
    }

    // Alternative 3.

    yyResult = pLiteral(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$4 = yyResult.semanticValue();

      yyValue = GNode.create("SimpleLiteralPattern", v$g$4);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 4.

    yyResult = pTuplePattern(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$5 = yyResult.semanticValue();

      yyValue = GNode.create("SimpleTuplePattern", v$g$5);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 5.

    yyResult = pStableId(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$6 = yyResult.semanticValue();

      final int yyChoice1 = yyResult.index;

      // Nested alternative 1.

      yyResult = pTuplePattern(yyChoice1);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        Node v$g$7 = yyResult.semanticValue();

        yyValue = GNode.create("SimpleCallPattern", v$g$6, v$g$7);
        yyValue.setLocation(location(yyStart));

        return yyResult.createValue(yyValue, yyError);
View Full Code Here

   *
   * @param n The expression node.
   * @return The function call java node.
   */
  public Node visitErrorClause(GNode n) {
    Node loc = (Node)dispatch(n.getGeneric(2));
    if (null == loc) loc = nullNode;
    //n.getGeneric(1).setProperty(NEWLET, Boolean.TRUE);
    Node letNode = (Node)dispatch(n.getGeneric(1));
    letNode = checkToLet(letNode, n.getGeneric(1).getProperty(TYPE));
    return factory.errorClause(n.getGeneric(0).getString(0), letNode,loc);
  }
View Full Code Here

      }
    }
    //n.getGeneric(0).setProperty(NEWLET, Boolean.TRUE);
    //n.getGeneric(1).setProperty(NEWLET, Boolean.TRUE);

    Node exp0 = (Node)dispatch(n.getGeneric(0));
    exp0 = checkToLet(exp0, n.getGeneric(0).getProperty(TYPE));

    Node exp1 = (Node)dispatch(n.getGeneric(1));
    exp1 = checkToLet(exp1, n.getGeneric(1).getProperty(TYPE));

    return (null == n.getGeneric(1))
      ? GNode.create("PostfixExpression", toIdentifier("assertion"),
          GNode.create("Arguments", exp0))
View Full Code Here

      n.getGeneric(1).setProperty(INANALYZE, Boolean.TRUE);
   

    List<String> upVars = getUpVariables(n);
    if (null != upVars) n.getGeneric(0).setProperty(UPVARS, upVars);
    Node left = (Node)dispatch(n.getGeneric(0));
    List<LetBinding> bl1 = getBindings(left);
       
    Node right = (Node)dispatch(n.getGeneric(1));
    right = checkToLet(right, n.getGeneric(1).getProperty(TYPE));
    Node ret = factory.ifExpression(left, right);
    if (null != bl1) ret.setProperty(LETBINDINGS, bl1);
    return ret;
  }
View Full Code Here

   */
  private Result pTuplePattern(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyBase;
    int        yyOption1;
    Node       yyOpValue1;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = psep(yyStart);
    if (yyResult.hasValue("(")) {

      yyOption1  = yyResult.index;
      yyOpValue1 = null;

      yyResult = pPatterns(yyOption1);
      yyError  = yyResult.select(yyError, yyOption1);
      if (yyResult.hasValue()) {
        Node v$el$1 = yyResult.semanticValue();

        yyOption1  = yyResult.index;
        yyOpValue1 = v$el$1;
      }
      { // Start scope for v$g$1.
        Node v$g$1 = yyOpValue1;

        yyBase   = yyOption1;
        yyResult = psep(yyBase);
        if (yyResult.hasValue(")")) {

View Full Code Here

      n.getGeneric(2).setProperty(INANALYZE, Boolean.TRUE);
    }

    List<String> upVars = getUpVariables(n);
    if (null != upVars) n.getGeneric(0).setProperty(UPVARS, upVars);
    Node left = (Node)dispatch(n.getGeneric(0));
    List<LetBinding> bl1 = getBindings(left);
   

    Node middle = (Node)dispatch(n.getGeneric(1));
    middle = checkToLet(middle, n.getGeneric(1).getProperty(TYPE));

    Node right = (Node)dispatch(n.getGeneric(2));
    right = checkToLet(right, n.getGeneric(2).getProperty(TYPE));

    Node ret = factory.ifElseExpression(left, middle, right);
    if (null != bl1) ret.setProperty(LETBINDINGS, bl1);
    return ret;
  }
View Full Code Here

    int        yyBase;
    int        yyRepetition1;
    Pair<Node> yyRepValue1;
    int        yyOption1;
    String     yyOpValue1;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = pPattern(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$1 = yyResult.semanticValue();

      yyRepetition1 = yyResult.index;
      yyRepValue1   = Pair.empty();
      while (true) {

        yyBase   = yyRepetition1;
        yyResult = psep(yyBase);
        if (yyResult.hasValue(",")) {

          yyResult = pPattern(yyResult.index);
          yyError  = yyResult.select(yyError, yyRepetition1);
          if (yyResult.hasValue()) {
            Node v$el$1 = yyResult.semanticValue();

            yyRepetition1 = yyResult.index;
            yyRepValue1   = new Pair<Node>(v$el$1, yyRepValue1);
            continue;
          }
View Full Code Here

  public Node visitRequireExpression(GNode n) {
   
    int nodeSize = n.size();
    // get the expression
    Node expr = n.getGeneric(nodeSize -1);
    passVariables(n, expr);

    if (n.hasProperty(INANALYZE)) expr.setProperty(INANALYZE, Boolean.TRUE);
    //dispatch this node to translate
    Node valExpr = (Node)dispatch(expr);

    final Node genericType;
    if (expr.hasProperty(TYPE)) {
      genericType = mapper.toTypeNode(expr.getProperty(TYPE), false);
    } else {
      genericType = GNode.create("Type",
                      GNode.create("QualifiedIdentifier", "Object"),
                      null);
    }
   
    ArrayList<Node> list = new ArrayList<Node>();
   
    for (int id = 0; id < nodeSize - 1; id++) {
      Node no = n.getGeneric(id);
      list.add(no);
    }

    // Create require block
    List<Node> requireBlock = new ArrayList<Node>();

    /* A list of translated expressions */
    ArrayList<Node> listExpr = new ArrayList<Node>();
   
    // Add statement
    for (Node node: list) {     
      Node boolNode = node.getGeneric(0);
      //boolNode.setProperty(NEWLET, Boolean.TRUE);
      if (n.hasProperty(INANALYZE)) {
        boolNode.setProperty(INANALYZE, Boolean.TRUE);
      }
      Node boolExpr = (Node)dispatch(boolNode);
      boolExpr = checkToLet(boolExpr, boolNode.getProperty(TYPE));

      final String newVar = table.freshJavaId("var");

      requireBlock.add(factory.boolVar(newVar, boolExpr));
     
      listExpr.add(toIdentifier(newVar));

      Node tagNode = node.getGeneric(1);
      String tag = tagNode.getString(0);

      Node msgNode = node.getGeneric(2);
      Node msgExpr = (Node)dispatch(msgNode);
 
      Node atNode = node.getGeneric(3);
      Node atExpr;
      if (null == atNode) {
        atExpr = nullNode;
      } else {
        atExpr = (Node)dispatch(atNode);
     
   
      Node ifNode = factory.ifStatement3(toIdentifier(newVar),
                                         GNode.create("StringLiteral",
                                           "\"" + tag + "\""), msgExpr,atExpr);
      requireBlock.add(ifNode);
    }

    // check for returning null (bottom)   
    if (1 == listExpr.size()) {
      Node checkNode = factory.ifStatement4(listExpr.get(0));
     
      requireBlock.add(checkNode);
    } else {
      Node logicalOr = GNode.create("LogicalOrExpression");
      logicalOr.add(factory.isNull(listExpr.get(0)));
      logicalOr.add(factory.isNull(listExpr.get(1)));
     
      for (int i = 2; i < listExpr.size(); i++ ) {
        logicalOr = GNode.create("LogicalOrExpression", logicalOr,
                                  factory.isNull(listExpr.get(i)));
      }
     
      Node checkNode = factory.ifStatement5(logicalOr);
      requireBlock.add(checkNode);
    }
   
    // Check to return expr

    if (1 == listExpr.size()) {
      Node checkNode;
      if(!"Block".equals(valExpr.getName())) {
        checkNode = factory.ifStatement(listExpr.get(0), factory.ret(valExpr));
      } else {
        checkNode = toIfStatement(listExpr.get(0), valExpr);
      }
      requireBlock.add(checkNode);
    } else {
      Node logicalAnd = GNode.create("LogicalAndExpression");
      logicalAnd.add(listExpr.get(0));
      logicalAnd.add(listExpr.get(1));
     
      for(int i = 2; i < listExpr.size(); i++) {
        logicalAnd = GNode.create("LogicalAndExpression", logicalAnd,
                                  listExpr.get(i));
      }
      Node checkNode;
      if (!"Block".equals(valExpr.getName())) {
        checkNode = factory.ifStatement(logicalAnd, factory.ret(valExpr));    
      } else {
        checkNode = toIfStatement(logicalAnd, valExpr);
      }
      requireBlock.add(checkNode);
    }
  
    // return null at the end
    requireBlock.add(factory.ret(nullNode));
    Node ret = factory.requireExpression(genericType, requireBlock);
    passBindings(valExpr, ret);
    return ret;
  }
View Full Code Here

  private Result pTypeParamClause(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyBase;
    int        yyRepetition1;
    Pair<Node> yyRepValue1;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = psep(yyStart);
    if (yyResult.hasValue("[")) {

      yyResult = pVariantTypeParam(yyResult.index);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        Node v$g$1 = yyResult.semanticValue();

        yyRepetition1 = yyResult.index;
        yyRepValue1   = Pair.empty();
        while (true) {

          yyBase   = yyRepetition1;
          yyResult = psep(yyBase);
          if (yyResult.hasValue(",")) {

            yyResult = pVariantTypeParam(yyResult.index);
            yyError  = yyResult.select(yyError, yyRepetition1);
            if (yyResult.hasValue()) {
              Node v$el$1 = yyResult.semanticValue();

              yyRepetition1 = yyResult.index;
              yyRepValue1   = new Pair<Node>(v$el$1, yyRepValue1);
              continue;
            }
View Full Code Here

TOP

Related Classes of xtc.tree.Node

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.