All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jastadd.ast.AST.OptionalComponent Maven / Gradle / Ivy

There is a newer version: 2.3.6
Show newest version
/* This file was generated with JastAdd2 (http://jastadd.org) version 2.2.2 */
package org.jastadd.ast.AST;
import java.util.*;
import java.io.*;
import org.jastadd.ast.AST.*;
import org.jastadd.jrag.*;
import org.jastadd.jrag.AST.ASTCompilationUnit;
import org.jastadd.jrag.AST.ASTBlock;
import org.jastadd.JastAdd;
import java.nio.charset.StandardCharsets;
import org.jastadd.jrag.AST.ASTAspectMethodDeclaration;
import org.jastadd.jrag.AST.ASTAspectRefineMethodDeclaration;
import org.jastadd.jrag.AST.ASTAspectFieldDeclaration;
import org.jastadd.jrag.ClassBodyObject;
import java.io.PrintStream;
import org.jastadd.ast.AST.Token;
import org.jastadd.ast.AST.SimpleNode;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jastadd.jrag.AST.ASTExpression;
import org.jastadd.jrag.Unparser;
import org.jastadd.Problem;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;
import java.util.regex.*;
import org.jastadd.Configuration;
import org.jastadd.tinytemplate.*;
/**
 * @ast node
 * @declaredat /jastadd/src/jastadd/ast/Ast.ast:70
 * @production OptionalComponent : {@link Component} ::= {@link Id};

 */
public class OptionalComponent extends Component implements Cloneable {
  /**
   * @aspect Comments
   * @declaredat /jastadd/src/jastadd/ast/Comments.jrag:206
   */
  public String componentString() {
    return "[" + getId().componentString() + "]";
  }
  /**
   * @aspect Comments
   * @declaredat /jastadd/src/jastadd/ast/Comments.jrag:246
   */
  public String componentHtml() {
    return "[" + getId().componentHtml() + "]";
  }
  /**
   * @aspect JaddCodeGen
   * @declaredat /jastadd/src/jastadd/ast/JaddCodeGen.jrag:641
   */
  public void jaddGen(int index, boolean publicModifier, ASTDecl decl) {
    TemplateContext tt = templateContext();
    tt.bind("OptType", config().optType() + "<" + getId().type() + ">");
    tt.bind("Type", getId().type());
    tt.bind("Name", getId().name());
    tt.bind("Index", String.valueOf(index));
    tt.bind("Host", decl.name());
    tt.bind("Modifier", publicModifier ? "public" : "private");

    parse(tt.expand("OptionalComponent"));
  }
  /**
   * @declaredat ASTNode:1
   */
  public OptionalComponent(int i) {
    super(i);
  }
  /**
   * @declaredat ASTNode:5
   */
  public OptionalComponent(Ast p, int i) {
    this(i);
    parser = p;
  }
  /**
   * @declaredat ASTNode:10
   */
  public OptionalComponent() {
    this(0);
  }
  /**
   * Initializes the child array to the correct size.
   * Initializes List and Opt nta children.
   * @apilevel internal
   * @ast method
   * @declaredat ASTNode:19
   */
  public void init$Children() {
    children = new ASTNode[1];
  }
  /**
   * @declaredat ASTNode:22
   */
  public OptionalComponent(Id p0) {
    setChild(p0, 0);
  }
  /**
   * @declaredat ASTNode:25
   */
  public void dumpTree(String indent, java.io.PrintStream out) {
    out.print(indent + "OptionalComponent");
    String childIndent = indent + "  ";
    for (int i = 0; i < getNumChild(); i++) {
      getChild(i).dumpTree(childIndent, out);
    }
  }
  /**
   * @declaredat ASTNode:32
   */
  public Object jjtAccept(AstVisitor visitor, Object data) {
    return visitor.visit(this, data);
  }
  /**
   * @declaredat ASTNode:35
   */
  public void jjtAddChild(Node n, int i) {
    checkChild(n, i);
    super.jjtAddChild(n, i);
  }
  /**
   * @declaredat ASTNode:39
   */
  public void checkChild(Node n, int i) {
    if (i == 0 && !(n instanceof Id)) {
     throw new Error("Child number 0 of OptionalComponent has the type " +
       n.getClass().getName() + " which is not an instance of Id");
    }
  }
  /** @apilevel low-level 
   * @declaredat ASTNode:46
   */
  public int getNumChild() {
    return 1;
  }
  /**
   * @apilevel internal
   * @declaredat ASTNode:52
   */
  public boolean mayHaveRewrite() {
    return false;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:56
   */
  public void flushAttrCache() {
    super.flushAttrCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:60
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:64
   */
  public OptionalComponent clone() throws CloneNotSupportedException {
    OptionalComponent node = (OptionalComponent) super.clone();
    return node;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:69
   */
  public OptionalComponent copy() {
    try {
      OptionalComponent node = (OptionalComponent) clone();
      node.parent = null;
      if (children != null) {
        node.children = (ASTNode[]) children.clone();
      }
      return node;
    } catch (CloneNotSupportedException e) {
      throw new Error("Error: clone not supported for " + getClass().getName());
    }
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @deprecated Please use treeCopy or treeCopyNoTransform instead
   * @declaredat ASTNode:88
   */
  @Deprecated
  public OptionalComponent fullCopy() {
    return treeCopyNoTransform();
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @declaredat ASTNode:98
   */
  public OptionalComponent treeCopyNoTransform() {
    OptionalComponent tree = (OptionalComponent) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) children[i];
        if (child != null) {
          child = child.treeCopyNoTransform();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The subtree of this node is traversed to trigger rewrites before copy.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @declaredat ASTNode:118
   */
  public OptionalComponent treeCopy() {
    doFullTraversal();
    return treeCopyNoTransform();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:123
   */
  protected boolean is$Equal(ASTNode node) {
    return super.is$Equal(node);    
  }
  /**
   * Replaces the Id child.
   * @param node The new node to replace the Id child.
   * @apilevel high-level
   */
  public void setId(Id node) {
    setChild(node, 0);
  }
  /**
   * Retrieves the Id child.
   * @return The current node used as the Id child.
   * @apilevel high-level
   */
  @ASTNodeAnnotation.Child(name="Id")
  public Id getId() {
    return (Id) getChild(0);
  }
  /**
   * Retrieves the Id child.
   * 

This method does not invoke AST transformations.

* @return The current node used as the Id child. * @apilevel low-level */ public Id getIdNoTransform() { return (Id) getChildNoTransform(0); } /** @apilevel internal */ protected int constrParmType_visited = -1; /** * @attribute syn * @aspect ConstructorParameterTypes * @declaredat /jastadd/src/jastadd/ast/ComponentsUtil.jrag:120 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="ConstructorParameterTypes", declaredAt="/jastadd/src/jastadd/ast/ComponentsUtil.jrag:120") public String constrParmType() { if (constrParmType_visited == state().boundariesCrossed) { throw new RuntimeException("Circular definition of attribute Component.constrParmType()."); } constrParmType_visited = state().boundariesCrossed; String constrParmType_value = config().optType() + "<" + getId().type() + ">"; constrParmType_visited = -1; return constrParmType_value; } /** @apilevel internal */ protected int name_visited = -1; /** * @attribute syn * @aspect Names * @declaredat /jastadd/src/jastadd/ast/ASTNameBinding.jrag:106 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="Names", declaredAt="/jastadd/src/jastadd/ast/ASTNameBinding.jrag:106") public String name() { if (name_visited == state().boundariesCrossed) { throw new RuntimeException("Circular definition of attribute Component.name()."); } name_visited = state().boundariesCrossed; String name_value = getId().name(); name_visited = -1; return name_value; } /** @apilevel internal */ protected int type_visited = -1; /** * @attribute syn * @aspect Types * @declaredat /jastadd/src/jastadd/ast/ASTNameBinding.jrag:121 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="Types", declaredAt="/jastadd/src/jastadd/ast/ASTNameBinding.jrag:121") public String type() { if (type_visited == state().boundariesCrossed) { throw new RuntimeException("Circular definition of attribute Component.type()."); } type_visited = state().boundariesCrossed; String type_value = getId().type(); type_visited = -1; return type_value; } /** @apilevel internal */ protected int kind_visited = -1; /** * @attribute syn * @aspect Kind * @declaredat /jastadd/src/jastadd/ast/ASTNameBinding.jrag:139 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="Kind", declaredAt="/jastadd/src/jastadd/ast/ASTNameBinding.jrag:139") public String kind() { if (kind_visited == state().boundariesCrossed) { throw new RuntimeException("Circular definition of attribute Component.kind()."); } kind_visited = state().boundariesCrossed; String kind_value = "Opt"; kind_visited = -1; return kind_value; } /** @apilevel internal */ protected java.util.Map checkComponentStructure_int_visited = new java.util.HashMap(4); /** * Check the structure of a single JJTree component. * @attribute syn * @aspect JaddCodeGen * @declaredat /jastadd/src/jastadd/ast/JaddCodeGen.jrag:499 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="JaddCodeGen", declaredAt="/jastadd/src/jastadd/ast/JaddCodeGen.jrag:499") public String checkComponentStructure(int childIndex) { Object _parameters = childIndex; if (Integer.valueOf(state().boundariesCrossed).equals(checkComponentStructure_int_visited.get(_parameters))) { throw new RuntimeException("Circular definition of attribute Component.checkComponentStructure(int)."); } checkComponentStructure_int_visited.put(_parameters, Integer.valueOf(state().boundariesCrossed)); try { TemplateContext tt = templateContext(); tt.bind("ChildIndex", "" + childIndex); tt.bind("HostClassName", hostClass().name()); return tt.expand("OptionalComponent.checkComponentStructure"); } finally { checkComponentStructure_int_visited.remove(_parameters); } } /** @apilevel internal */ protected int annotations_visited = -1; /** * @attribute syn * @aspect Annotations * @declaredat /jastadd/src/jastadd/ast/Annotations.jrag:109 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="Annotations", declaredAt="/jastadd/src/jastadd/ast/Annotations.jrag:109") public String annotations() { if (annotations_visited == state().boundariesCrossed) { throw new RuntimeException("Circular definition of attribute OptionalComponent.annotations()."); } annotations_visited = state().boundariesCrossed; String annotations_value = ""; annotations_visited = -1; return annotations_value; } /** @apilevel internal */ public ASTNode rewriteTo() { return super.rewriteTo(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy