Package xtc.tree

Examples of xtc.tree.Node


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

    // Alternative 1.

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


   * @param n The if statement node
   * @param no The node annotated with bindings
   * @return The if statement with bindings added
   */
  public Node addToIf(Node n, Node no) {
    Node block = n.getGeneric(1);
    int size = block.size();
    // Get the last return statement of the block
    Node retNode = block.getGeneric(size - 1);
    block.set(size - 1, null);

    List<LetBinding> bl = getBindings(no);

    if (null != bl) {
View Full Code Here

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

    // Alternative 1.

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

      yyResult = pAnnotation(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();

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

        yyOption1  = yyResult.index;
        yyOpValue1 = null;

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

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

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

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

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

     
    } else if ("TypeConstructorPattern".equals(nodeName)) {
      if (1 == node.size() || "WidlCard".equals(node.getGeneric(1).getName())) {
        return null;
      } else {
        Node paras = node.getGeneric(1);
        boolean hasBinding = false;

        for (int index = 0; index < paras.size(); index++) {
          res = getIndexList(paras.getGeneric(index));
          if (null != res && !res.isEmpty()) {
            if ("ConsPattern".equals(paras.getGeneric(index).getName())||
                "ListPattern".equals(paras.getGeneric(index).getName())) {
              int pos = res.remove(0);
              res.add(0, pos + index);
              return res;
            } else {
              res.add(0, index);
View Full Code Here

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

    // Alternative 1.

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

      final int yyChoice1 = yyResult.index;

      // Nested alternative 1.

      yyBase   = yyChoice1;
      yyResult = pop(yyBase);
      if (yyResult.hasValue("*")) {
        String v$g$2 = "*";

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

        return yyResult.createValue(yyValue, yyError);
      } else {
        yyError = yyError.select("'*' expected", yyBase);
      }

      // Nested alternative 2.

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

      return new SemanticValue(yyValue, yyChoice1, yyError);
    }

    // Alternative 2.

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

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

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

        return yyResult.createValue(yyValue, yyError);
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 = pClassParamClause(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 = pClassParams(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("ClassParamClauses", v$g$1, v$g$2);
        yyValue.setLocation(location(yyStart));

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

   */
  private Result pClassParamClause(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 = pClassParams(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

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

    // Alternative 1.

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

     
    //create the function name and parameterise it with the return type
    //and the argument types
    final int paraSize = paramTypes.size() - args.size();

    Node typeArgs = GNode.create("TypeArguments");
    typeArgs.add(retType);

    for (int i = args.size(); i < paramTypes.size(); i++) {
      typeArgs.add(paramTypes.get(i));
    }     
   
    Node functionTypeNode = GNode.create("Type",
                 GNode.create("InstantiatedType",
                   GNode.create("TypeInstantiation", "Function", null),
                   GNode.create("TypeInstantiation", "F" + paraSize,
                                typeArgs)),
                 null);

    // Populate the formal parameters for the "apply" method
    Node formalParameters = GNode.create("FormalParameters", paraSize);
    // Names of formal parameters
    List<String> formalParams = new ArrayList<String>();
 
    for (int i = args.size(); i < paramTypes.size(); i++) {
      String newPara = table.freshJavaId("para");
      formalParams.add(newPara);
      formalParameters.add(GNode.create("FormalParameter", fmod,
        paramTypes.get(i), null, newPara, null));
    }
   
    // Create block for apply method
    Node block = GNode.create("Block");
    // Names of temporary variables
    List<String> tempVars = new ArrayList<String>();
   
    for (int i = 0; i < args.size(); i++) {
      // Assign to a temporary variable
      String tempVar = table.freshJavaId("var");
      tempVars.add(tempVar);
      block.add(factory.fieldDecl2(paramTypes.get(i),
                                   tempVar, args.getGeneric(i)));     
    }
 
    // Node of new arguments
    Node newArgs = GNode.create("Arguments");
   
    for (String s : tempVars) newArgs.add(toIdentifier(s));
    for (String s : formalParams) newArgs.add(toIdentifier(s));
   
    // Create return statement
    Node ret = factory.ret(factory.apply(toIdentifier(funcName),
                                         makeArgumentList(newArgs)));
    block.add(ret);

    // Create body of the class
    Node classBody = GNode.create("ClassBody",
      GNode.create("MethodDeclaration", pmod, null,
      retType, "apply", formalParameters, null, null,
      block));
    return toNewExpression2(functionTypeNode,null,classBody);       
View Full Code Here

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

    // Alternative 1.

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

      yyResult = pAnnotation(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;

      yyResult = pClassParam$$Choice1(yyOption1);
      yyError  = yyResult.select(yyError, yyOption1);
      if (yyResult.hasValue()) {
        Pair<Node> v$el$2 = yyResult.semanticValue();

        yyOption1  = yyResult.index;
        yyOpValue1 = v$el$2;
      }
      { // Start scope for v$g$2.
        Pair<Node> v$g$2 = cast(yyOpValue1);

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

          yyOption1  = yyResult.index;
          yyOpValue1 = null;

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

            yyResult = pParamType(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 = cast(yyOpValue1);

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

            return new SemanticValue(yyValue, yyOption1, yyError);
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.