~ubuntu-branches/ubuntu/vivid/sablecc/vivid

« back to all changes in this revision

Viewing changes to src/org/sablecc/sablecc/node/AHelpers.java

  • Committer: Bazaar Package Importer
  • Author(s): Etienne M. Gagnon
  • Date: 2004-01-25 13:28:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040125132801-0so74ui506b30b1q
Tags: 2.18.2-1
* New upstream release.
* Keep the org.sablecc.ant.taskdef.Sablecc ant task of the upstream
  package, closes: #213020.
* Improve man page.
* Update Standards-Version to 3.6.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file was generated by SableCC (http://www.sablecc.org/). */
 
2
 
 
3
package org.sablecc.sablecc.node;
 
4
 
 
5
import java.util.*;
 
6
import org.sablecc.sablecc.analysis.*;
 
7
 
 
8
public final class AHelpers extends PHelpers
 
9
{
 
10
  private THelpers _helpers_;
 
11
  private final LinkedList _helperDefs_ = new TypedLinkedList(new HelperDefs_Cast());
 
12
 
 
13
  public AHelpers()
 
14
  {}
 
15
 
 
16
  public AHelpers(
 
17
    THelpers _helpers_,
 
18
    List _helperDefs_)
 
19
  {
 
20
    setHelpers(_helpers_);
 
21
 
 
22
    {
 
23
      this._helperDefs_.clear();
 
24
      this._helperDefs_.addAll(_helperDefs_);
 
25
    }
 
26
 
 
27
  }
 
28
 
 
29
  public AHelpers(
 
30
    THelpers _helpers_,
 
31
    XPHelperDef _helperDefs_)
 
32
  {
 
33
    setHelpers(_helpers_);
 
34
 
 
35
    if(_helperDefs_ != null)
 
36
    {
 
37
      while(_helperDefs_ instanceof X1PHelperDef)
 
38
      {
 
39
        this._helperDefs_.addFirst(((X1PHelperDef) _helperDefs_).getPHelperDef());
 
40
        _helperDefs_ = ((X1PHelperDef) _helperDefs_).getXPHelperDef();
 
41
      }
 
42
      this._helperDefs_.addFirst(((X2PHelperDef) _helperDefs_).getPHelperDef());
 
43
    }
 
44
 
 
45
  }
 
46
  public Object clone()
 
47
  {
 
48
    return new AHelpers(
 
49
             (THelpers) cloneNode(_helpers_),
 
50
             cloneList(_helperDefs_));
 
51
  }
 
52
 
 
53
  public void apply(Switch sw)
 
54
  {
 
55
    ((Analysis) sw).caseAHelpers(this);
 
56
  }
 
57
 
 
58
  public THelpers getHelpers()
 
59
  {
 
60
    return _helpers_;
 
61
  }
 
62
 
 
63
  public void setHelpers(THelpers node)
 
64
  {
 
65
    if(_helpers_ != null)
 
66
    {
 
67
      _helpers_.parent(null);
 
68
    }
 
69
 
 
70
    if(node != null)
 
71
    {
 
72
      if(node.parent() != null)
 
73
      {
 
74
        node.parent().removeChild(node);
 
75
      }
 
76
 
 
77
      node.parent(this);
 
78
    }
 
79
 
 
80
    _helpers_ = node;
 
81
  }
 
82
 
 
83
  public LinkedList getHelperDefs()
 
84
  {
 
85
    return _helperDefs_;
 
86
  }
 
87
 
 
88
  public void setHelperDefs(List list)
 
89
  {
 
90
    _helperDefs_.clear();
 
91
    _helperDefs_.addAll(list);
 
92
  }
 
93
 
 
94
  public String toString()
 
95
  {
 
96
    return ""
 
97
           + toString(_helpers_)
 
98
           + toString(_helperDefs_);
 
99
  }
 
100
 
 
101
  void removeChild(Node child)
 
102
  {
 
103
    if(_helpers_ == child)
 
104
    {
 
105
      _helpers_ = null;
 
106
      return;
 
107
    }
 
108
 
 
109
    if(_helperDefs_.remove(child))
 
110
    {
 
111
      return;
 
112
    }
 
113
 
 
114
  }
 
115
 
 
116
  void replaceChild(Node oldChild, Node newChild)
 
117
  {
 
118
    if(_helpers_ == oldChild)
 
119
    {
 
120
      setHelpers((THelpers) newChild);
 
121
      return;
 
122
    }
 
123
 
 
124
    for(ListIterator i = _helperDefs_.listIterator(); i.hasNext();)
 
125
    {
 
126
      if(i.next() == oldChild)
 
127
      {
 
128
        if(newChild != null)
 
129
        {
 
130
          i.set(newChild);
 
131
          oldChild.parent(null);
 
132
          return;
 
133
        }
 
134
 
 
135
        i.remove();
 
136
        oldChild.parent(null);
 
137
        return;
 
138
      }
 
139
    }
 
140
 
 
141
  }
 
142
 
 
143
  private class HelperDefs_Cast implements Cast
 
144
  {
 
145
    public Object cast(Object o)
 
146
    {
 
147
      PHelperDef node = (PHelperDef) o;
 
148
 
 
149
      if((node.parent() != null) &&
 
150
          (node.parent() != AHelpers.this))
 
151
      {
 
152
        node.parent().removeChild(node);
 
153
      }
 
154
 
 
155
      if((node.parent() == null) ||
 
156
          (node.parent() != AHelpers.this))
 
157
      {
 
158
        node.parent(AHelpers.this);
 
159
      }
 
160
 
 
161
      return node;
 
162
    }
 
163
  }
 
164
}