Package xtc.tree

Examples of xtc.tree.Node


   * @param bl The list of variable bindings.
   * @param retType The type of that expression.
   * @return the converted node.
   */
  private Node convertToLet(Node n, List<LetBinding> bl, Object retType) {
    Node block = null;
    if ("Block".equals(n.getName())) {
      block = GNode.create("Block", n);
    } else {
      // fix cast here
      if (mapper.hasTypeVariables(retType)) {
        block = GNode.create("Block", factory.ret(n));
      } else {
        block = GNode.create("Block", factory.ret(factory.cast(n)));
      }
    }
    Node letclass = GNode.create("ClassBody");
    letclass = GNode.ensureVariable((GNode)letclass);
    GNode letbody = GNode.create("Block");

    for (LetBinding bind : bl) {
      if (!bind.name.equals(spareVar)) {
        letclass.add(makeVarDec2(bind.name, bind.type , null));
      }
      if (mapper.hasTypeVariables(bind.typeObject)) {
        letbody.add(factory.assign(toIdentifier(bind.name), bind.value));
      } else {
        letbody.add(factory.assign(toIdentifier(bind.name),
                                   factory.cast(bind.value)));
      }
    }

    if (letbody.size() > 0) {
      letclass.add(letbody);
    }
   
    letclass.add(GNode.create("MethodDeclaration",
      toModifiers("public"),null, mapper.toTypeNode(retType, false),
      "apply", GNode.create("FormalParameters"), null, null, block));
   
    Node let = factory.letExpression(mapper.toTypeNode(retType, false));
    let.getGeneric(0).set(4, letclass);
    return let;   
  }
View Full Code Here


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

    // Alternative 1.

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

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

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 2.

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

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

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

   * Process a Patterns node.
   *
   * @return The patterns node corresponding to this node.
   */
  public Node visitPatterns(GNode n) {
    Node pat = n.getGeneric(0);
  
    if (n.hasProperty(TOP)) pat.setProperty(TOP, null);

    if (isLiteral(pat)) {
      return factory.jequals((Node)dispatch(pat),
                             toIdentifier((String)n.getProperty(MATCHARG)));
    } else {
      pat.setProperty(MATCHARG, n.getProperty(MATCHARG));
      pat.setProperty(BINDINGS, n.getProperty(BINDINGS));
      pat.setProperty(RHS, n.getProperty(RHS));
      return (GNode)dispatch(pat);
    }
  } 
View Full Code Here

  /** Actually parse org.netbeans.modules.scala.core.rats.ParserScala.ResultFunExpr. */
  private Result pResultFunExpr$1(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyBase;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

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

      yyBase   = yyResult.index;
      yyResult = pkey(yyBase);
      if (yyResult.hasValue("=>")) {

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

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

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

   */
  private Result pResultFunExpr$$Choice1(final int yyStart)
    throws IOException {

    Result     yyResult;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = pBindings(yyStart);
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);
    List<String> vars = extractVariables(bl1);
    upVars = groupList(upVars,vars);

    if (null != upVars) n.getGeneric(2).setProperty(UPVARS, upVars);
    Node right = (Node)dispatch(n.getGeneric(2));
    List<LetBinding> bl2 = getBindings(right);
    bl1 = groupList(bl1, bl2);
    Node ret;   
   
    if ("+".equals(op))  ret = factory.addInt(left, right);
    else if ("-".equals(op))  ret = factory.subtractInt(left, right);
    else if ("+.".equals(op)) ret = factory.addFloat64(left, right);
    else ret = factory.subtractFloat64(left, right);
    if (null != bl1) ret.setProperty(LETBINDINGS, bl1);
    return ret;
  }
View Full Code Here

   */
  private Result pResultBinding(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyBase;
    int        yyOption1;
    Node       yyOpValue1;
    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;
      yyOpValue1 = null;

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

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

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

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

        return new SemanticValue(yyValue, yyOption1, yyError);
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);
    List<String> vars = extractVariables(bl1);
    upVars = groupList(upVars,vars);

    if (null != upVars) n.getGeneric(2).setProperty(UPVARS, upVars);
    Node right = (Node)dispatch(n.getGeneric(2));
    List<LetBinding> bl2 = getBindings(right);
    bl1 = groupList(bl1, bl2);
    Node ret;       
   
    if ("^".equals(n.getString(1))) ret = factory.concatStrings(left, right);
    else ret = factory.concatLists(left, right);

    if (null != bl1) ret.setProperty(LETBINDINGS, bl1);
    return ret;
  }
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);
    List<String> vars = extractVariables(bl1);
    upVars = groupList(upVars,vars);

    if (null != upVars) n.getGeneric(2).setProperty(UPVARS, upVars);
    Node right = (Node)dispatch(n.getGeneric(2));
    List<LetBinding> bl2 = getBindings(right);
    bl1 = groupList(bl1, bl2);
    Node ret;           
   
    if ("*".equals(op))  ret = factory.multiplyInt(left, right);
    else if ("/".equals(op))  ret = factory.divideInt(left, right);
    else if ("%".equals(op))  ret = factory.modInt(left, right);
    else if ("*.".equals(op)) ret = factory.multiplyFloat64(left, right);
    else ret = factory.divideFloat64(left, right);

    if (null != bl1) ret.setProperty(LETBINDINGS, bl1);
    return ret;
  }
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);
    List<String> vars = extractVariables(bl1);
    upVars = groupList(upVars,vars);

    if (null != upVars) n.getGeneric(2).setProperty(UPVARS, upVars);
    Node right = (Node)dispatch(n.getGeneric(2));
    List<LetBinding> bl2 = getBindings(right);
    bl1 = groupList(bl1, bl2);
    Node ret;               
 
    String op = n.getString(1);
    String internal = null;
   
    if ("<".equals(op))   internal = "lessInt";
    if ("<=".equals(op))  internal = "lessEqualInt";
    if (">".equals(op))   internal = "greaterInt";
    if (">=".equals(op))  internal = "greaterEqualInt";
    if ("<.".equals(op))  internal = "lessFloat64";
    if ("<=.".equals(op)) internal = "lessEqualFloat64";
    if (">.".equals(op))  internal = "greaterFloat64";
    if (">=.".equals(op)) internal = "greaterEqualFloat64";
    assert null != internal : "undefined relational operator " + op;
    
    ret =
      factory.relationalExpr(toIdentifier("Primitives." + internal),left,right);
    if (null != bl1) ret.setProperty(LETBINDINGS, bl1);
    return ret;
  }
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.