Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. /* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 6.0 */
  2. /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
  3. public
  4. class SimpleNode implements Node {
  5.  
  6. protected Node parent;
  7. protected Node[] children;
  8. protected int id;
  9. protected Object value;
  10. protected jmm parser;
  11.  
  12. public String name;
  13. public String valueInt;
  14. public String valueBoolean;
  15.  
  16. public SimpleNode(int i) {
  17. id = i;
  18. }
  19.  
  20. public SimpleNode(jmm p, int i) {
  21. this(i);
  22. parser = p;
  23. }
  24.  
  25. public void jjtOpen() {
  26. }
  27.  
  28. public void jjtClose() {
  29. }
  30.  
  31. public void jjtSetParent(Node n) { parent = n; }
  32. public Node jjtGetParent() { return parent; }
  33.  
  34. public void jjtAddChild(Node n, int i) {
  35. if (children == null) {
  36. children = new Node[i + 1];
  37. } else if (i >= children.length) {
  38. Node c[] = new Node[i + 1];
  39. System.arraycopy(children, 0, c, 0, children.length);
  40. children = c;
  41. }
  42. children[i] = n;
  43. }
  44.  
  45. public Node jjtGetChild(int i) {
  46. return children[i];
  47. }
  48.  
  49. public int jjtGetNumChildren() {
  50. return (children == null) ? 0 : children.length;
  51. }
  52.  
  53. public void jjtSetValue(Object value) {
  54. this.value = value;
  55. }
  56.  
  57. public Object jjtGetValue() { return value; }
  58.  
  59. /* You can override these two methods in subclasses of SimpleNode to
  60. customize the way the node appears when the tree is dumped. If
  61. your output uses more than one line you should override
  62. toString(String), otherwise overriding toString() is probably all
  63. you need to do. */
  64.  
  65. public String toString() {
  66. return jmmTreeConstants.jjtNodeName[id];
  67. }
  68. public String toString(String prefix) { return prefix + toString(); }
  69.  
  70. /* Override this method if you want to customize how the node dumps
  71. out its children. */
  72.  
  73. public void dump(String prefix) {
  74.  
  75. System.out.print(toString(prefix) + " (");
  76. if(name != null)
  77. System.out.print("Name: " + name);
  78. if(valueBoolean != null)
  79. System.out.print("ValueBoolean: " + valueBoolean);
  80. if(valueInt != null)
  81. System.out.print("ValueInt: " + valueInt);
  82. System.out.println(")");
  83.  
  84. if (children != null) {
  85. for (int i = 0; i < children.length; ++i) {
  86. SimpleNode n = (SimpleNode)children[i];
  87. if (n != null) {
  88. n.dump(prefix + " ");
  89. }
  90. }
  91. }
  92. }
  93.  
  94. public int getId() {
  95. return id;
  96. }
  97. }
  98.  
  99. /* JavaCC - OriginalChecksum=b715587beecfd28b0e03367f901ce94f (do not edit this line) */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement