ASequenceExpression.java revision 56ed4167b942ec265f9cee70ac4d71d10b3835ce
1/* This file was generated by SableCC (http://www.sablecc.org/). */
2
3package com.google.clearsilver.jsilver.syntax.node;
4
5import java.util.*;
6import com.google.clearsilver.jsilver.syntax.analysis.*;
7
8@SuppressWarnings("nls")
9public final class ASequenceExpression extends PExpression
10{
11    private final LinkedList<PExpression> _args_ = new LinkedList<PExpression>();
12
13    public ASequenceExpression()
14    {
15        // Constructor
16    }
17
18    public ASequenceExpression(
19        @SuppressWarnings("hiding") List<PExpression> _args_)
20    {
21        // Constructor
22        setArgs(_args_);
23
24    }
25
26    @Override
27    public Object clone()
28    {
29        return new ASequenceExpression(
30            cloneList(this._args_));
31    }
32
33    public void apply(Switch sw)
34    {
35        ((Analysis) sw).caseASequenceExpression(this);
36    }
37
38    public LinkedList<PExpression> getArgs()
39    {
40        return this._args_;
41    }
42
43    public void setArgs(List<PExpression> list)
44    {
45        this._args_.clear();
46        this._args_.addAll(list);
47        for(PExpression e : list)
48        {
49            if(e.parent() != null)
50            {
51                e.parent().removeChild(e);
52            }
53
54            e.parent(this);
55        }
56    }
57
58    @Override
59    public String toString()
60    {
61        return ""
62            + toString(this._args_);
63    }
64
65    @Override
66    void removeChild(@SuppressWarnings("unused") Node child)
67    {
68        // Remove child
69        if(this._args_.remove(child))
70        {
71            return;
72        }
73
74        throw new RuntimeException("Not a child.");
75    }
76
77    @Override
78    void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
79    {
80        // Replace child
81        for(ListIterator<PExpression> i = this._args_.listIterator(); i.hasNext();)
82        {
83            if(i.next() == oldChild)
84            {
85                if(newChild != null)
86                {
87                    i.set((PExpression) newChild);
88                    newChild.parent(this);
89                    oldChild.parent(null);
90                    return;
91                }
92
93                i.remove();
94                oldChild.parent(null);
95                return;
96            }
97        }
98
99        throw new RuntimeException("Not a child.");
100    }
101}
102