Package xtc.tree

Examples of xtc.tree.Node


   * Process an attribute declaration.
   *
   * @param n the attribute declaration node to process.
   */
  public void visitAttributeDefinition(GNode n) {
    Node typeNode = n.getGeneric(1);
    if ("ConstraintType".equals(typeNode.getName())) {
      typeNode = GNode.create("UserDefinedType","Node");
    }
    attributeList.add(new Attribute(n.getString(0), typeNode));
  }
View Full Code Here


  }

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

    // Alternative 1.

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

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

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 2.

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

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

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

   * Process an equal attribute definition.
   *
   * @param n the equal attribute definition node to process.
   */
  public void visitEqualAttributeDefinition(GNode n) {
    Node typeNode = n.getGeneric(1);
    if ("ConstraintType".equals(typeNode.getName())) {
      typeNode = GNode.create("UserDefinedType","Node");
    }
    eqAttributeList.add(new Attribute(n.getString(0), typeNode));    
  }
View Full Code Here

   *
   * @return The node of generated code for "type" record definition.
   */
  public Node processRawTypeDefinition() {
    //Create type
    Node typeInfo =
      GNode.create("RecordDeclaration",GNode.create("FieldType", "type",
        GNode.create("UserDefinedType", "raw_type<?>")));

    typeInfo = GNode.ensureVariable((GNode)typeInfo);
     
    typeInfo.setProperty(TYPE, table.current().lookup("type(type)"));
   
    //Create equal attributes
    for (Attribute att : eqAttributeList) {
      typeInfo.add(GNode.create("FieldType", att.name, att.type));
    }
  
    //Create attributes
    for (Attribute att : attributeList) {
      typeInfo.add(GNode.create("FieldType", att.name, att.type));
    }
   
    return GNode.create("TypeDefinition", null, "type", typeInfo);  
  }
View Full Code Here

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

    // Alternative 1.

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

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

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

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

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

              yyResult = pPattern1(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 void visitEqualityDefinition(GNode n) {
    // process equal structure
    for (int index = 1; index < n.size(); index ++) {
      boolean seenLowerID = false;
      Node child = (GNode)n.get(index);
      ArrayList<Integer> list = new ArrayList<Integer>();

      for (int i = 1; i < child.size(); i++) {
        if (!("WildCard".equals(child.getGeneric(i).getName()))) {
          list.add(i);
          seenLowerID = true;         
        }        
      }
     
      if (!seenLowerID) {
        throw new AssertionError("At least one identifier required");       
      }
      equalities.add(new Equality((child.getGeneric(0)).getString(0),list));
    }
  }
View Full Code Here

  }

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

    // Alternative 1.

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

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

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 2.

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

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

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

   *
   * @param n The scope definition node
   */ 
  public void visitScopeDefinition(GNode n) {  
    // Adding code to build the list of node names that need to process scope
    Node pat = n.getGeneric(0);
    for (int i = 0; i < pat.size(); i++) {
      Node patterns = pat.getGeneric(i).getGeneric(0);
      for (int j = 0; j < patterns.size(); j++) {
        processScopeNodes.add(getNodeName(patterns.getGeneric(j)));        
      }
    }
 
    Node match = GNode.create("MatchExpression",
       GNode.create("LowerID","n"), n.getGeneric(0));
    match.setProperty("__arg_type", n.getProperty("__arg_type"));
    match.setProperty(TYPE,
      mapper.getPatternMatchRightType(n.getProperty(TYPE)));
   
    seenScope = true;

    Node pmatch = n.getGeneric(0);
    pmatch.setProperty(MATCHARG, "n");

    @SuppressWarnings("unchecked")
    List<Node> nodes = (List<Node>)dispatch(pmatch);
   
    nodes.add(factory.ret(GNode.create("NullLiteral")));
  
    // Create typical AST
    Node top = GNode.create("ValueDefinition",
                 "getScope",
                 GNode.create("Parameters",
                   GNode.create("Parameter",
                     "n",
                     GNode.create("UserDefinedType",
                       "node")
                   )
                 ),
                 GNode.create("BooleanLiteral", "true")
               );
           
    top.setProperty(TYPE, table.current().lookup("value(getScope)"));
    top.setProperty("__isfunction", null);
      
    Node block = GNode.create("Block");

    for (Node node : nodes) block.add(node);
   
    Node scopefunc = (Node)dispatch(top);

    scopefunc.getGeneric(2).getGeneric(0).getGeneric(2).getGeneric(4).
      getGeneric(0).set(7, block);

    functionDefinitions.add(scopefunc);
    return;
  }
View Full Code Here

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

    // Alternative 1.

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

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

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

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

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

    // Alternative 2.

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

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

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

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

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

  }

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

    // Alternative 1.

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

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

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 2.

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

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

      return yyResult.createValue(yyValue, 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.