Package xtc.tree

Examples of xtc.tree.Node


  private Result pFunTypeParamClause(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 = pTypeParam(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 = pTypeParam(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


    return ret;
  }
 
  /** Store nodes that need to process scopes. */
  public void processScopeSpace() {
    Node block = GNode.create("Block");
   
    for (int i = 0; i < processScopeNodes.size(); i++) {
      Node add = factory.addScopeNode(toIdentifier(
                                      "\"" + processScopeNodes.get(i) + "\""));
      block.add(add);

    }  
 
    Node getNodes = factory.getScopeNodesMethod();
    getNodes.set(7, block);
   
    cbody.add(getNodes);

    // if scope definition is not used
    if(!seenScope) {
View Full Code Here

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

    // Alternative 1.

    yyOption1  = yyStart;
    yyOpValue1 = null;

    yyResult = pVariantTypeParam$$Choice1(yyOption1);
    yyError  = yyResult.select(yyError, yyOption1);
    if (yyResult.hasValue()) {
      String v$el$1 = yyResult.semanticValue();

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

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

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

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

   *
   * @return The equals method for the type record.
   */
  public Node createTypeRecordEquals() {

    Node block = GNode.create("Block");

    block.add(toIfStatement(factory.equality(toIdentifier("o"), nullNode),
      factory.ret(GNode.create("BooleanLiteral","false"))));
                       
    block.add(toIfStatement(GNode.create("LogicalNegationExpression",
      GNode.create("InstanceOfExpression", toIdentifier("o"), toType("type"))),
        factory.ret(toLiteral("BooleanLiteral","false"))) );
    block.add(factory.recordFieldEqual());
   
    block.add(factory.recordEqualReturn());

    block.add(factory.compareTypes());
   
    // Add equal attribute comparisons.
    for (Attribute att : eqAttributeList) {
      block.add(factory.compareAttributes(toIdentifier(att.name)));     
    }
    block.add(factory.ret(toIdentifier("res")));

    Node retNode = factory.equalsMethod();
    retNode.set(7, block);
    return retNode;
  }
View Full Code Here

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

    // Alternative 1.

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

      yyOption1  = yyResult.index;
      yyOpValue1 = null;

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

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

        yyOpValue1 = null;

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

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

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

          yyOpValue1 = null;

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

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

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

            yyOpValue1 = null;

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

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

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

              yyValue = GNode.create("TypeParam", v$g$1, v$g$2, v$g$3, v$g$4, v$g$5);
              yyValue.setLocation(location(yyStart));

              return new SemanticValue(yyValue, yyOption1, yyError);
View Full Code Here

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

    // Alternative 1.

    yyResult = pId(yyStart);
View Full Code Here

      }
    }
   
    assert null != constr : "null value for constr"
        
    Node block = GNode.create("Block");
    block.add(factory.ifStatement1(toIdentifier("o")));

    Node secondIf = factory.ifStatement2(toIdentifier("o"));
    secondIf.getGeneric(0).getGeneric(0).set(1, toType(variantName));
    block.add(secondIf);
    block.add(makeDec("other", variantName, GNode.create("CastExpression",
         toType(variantName), toIdentifier("o"))));
    block.add(makeDec("res", "boolean", toLiteral("BooleanLiteral","true")));
      
    for (Integer pos : constr.positions) {
      block.add(factory.compareMembers(
                  "getTuple().get" + pos + "()"));     
    }
    block.add(factory.ret(toIdentifier("res")));
    Node foo = factory.equalsMethod();
    foo.set(7, block);
    return foo;
  }
View Full Code Here

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

    // Alternative 1.

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

      yyResult = pParamClause(yyRepetition1);
      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;
      }
      break;
    }
    { // Start scope for v$g$1.
      Pair<Node> v$g$1 = yyRepValue1.reverse();

      yyOption1  = yyRepetition1;
      yyOpValue1 = null;

      yyOption2  = yyOption1;

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

        yyOption2  = yyResult.index;
      }

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

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

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

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

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

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

        return new SemanticValue(yyValue, yyOption1, yyError);
View Full Code Here

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

    // Alternative 1.

    yyOption1  = yyStart;

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

      yyOption1  = yyResult.index;
    }

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

      yyOption1  = yyResult.index;
      yyOpValue1 = null;

      yyResult = pParams(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

   * @param no The pattern match node.
   * @param bn The node to get bindings from (if exists).
   * @return The augmented IfStatement.
   */
  public Node augmentIfStatement(Node n, String matchArg, GNode no, Node bn) {
    Node block = n.getGeneric(1);
    GNode pattern = no.getGeneric(0).getGeneric(0);
    List<Integer> indexList = getIndexList(pattern);

    int size = block.size();
    // Get the last return statement of the block
    Node retNode = block.getGeneric(size - 1);

    assert ("ReturnStatement" == retNode.getName()) :
      "The last statement of the if block is not a return statement";

    // Update matching_nodes.
    block.set(size - 1, factory.matchingNodesAdd(toIdentifier(matchArg)));
    // Check if this node needs to process scope
    block.add(factory.processScope(toIdentifier(matchArg)));
    // Check if enter a new scope
    block.add(factory.checkEnterScope(toIdentifier(matchArg)));
    // Check if needed to process scope of the offsprings
    String nodeName = table.freshJavaId("nodeName");
    String listName = table.freshJavaId("listName");
    if (null != indexList && indexList.size() > 1) {
      block.add(factory.spOffspringList(listName));
      block.add(factory.spRunNode(nodeName, toIdentifier(matchArg)));
      int index;
      for (int ind = 0; ind < indexList.size() - 1; ind++){
        index = indexList.get(ind);
        block.add(factory.spGetGeneric(toIdentifier(nodeName),
          toLiteral("IntegerLiteral", "" + index)));
        block.add(factory.processScope(toIdentifier(nodeName)));
        block.add(factory.checkEnterScope(toIdentifier(nodeName)));
        block.add(factory.spOffspringListAdd(toIdentifier(listName),
                                             toIdentifier(nodeName)));
      }
    }
    // Add bindings if exists
    List<LetBinding> bl = getBindings(bn);
     
    if (null != bl) {
      for (LetBinding bind : bl) {
        if (!bind.name.equals(spareVar)) {
          if (mapper.hasTypeVariables(bind.typeObject)) {
            block.add(factory.fieldDecl2(bind.type, bind.name, bind.value));
          } else {
            block.add(factory.fieldDecl2(bind.type, bind.name,
                      factory.cast(bind.value)));
          }
        } else {
          if (mapper.hasTypeVariables(bind.typeObject)) {
            block.add(factory.assign(toIdentifier(bind.name), bind.value));
          } else {
            block.add(factory.assign(toIdentifier(bind.name),
                      factory.cast(bind.value)));
          }
        }
      }
    }

    // Store the return value
    String freshId = table.freshJavaId("retValue");
    block.add(factory.storeValue(freshId, retNode.getGeneric(0)));
    // Check to exit scope
    if (null != indexList && indexList.size() > 1) {
      block.add(factory.spForLoop(toIdentifier(listName)));
    }
    block.add(factory.checkExitScope(toIdentifier(matchArg)));
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.