01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2005-2007 Robert Grimm
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * version 2 as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17: * USA.
18: */
19: package xtc.parser;
20:
21: /**
22: * An alternative addition. The superclass's attributes are ignored.
23: *
24: * @author Robert Grimm
25: * @version $Revision: 1.5 $
26: */
27: public class AlternativeAddition extends PartialProduction {
28:
29: /** The sequence relative to which the choice is to be added. */
30: public SequenceName sequence;
31:
32: /**
33: * The flag for whether the choice is to be added after or before
34: * the sequence.
35: */
36: public boolean isBefore;
37:
38: /**
39: * Create a new alternative addition.
40: *
41: * @param dType The declared type.
42: * @param name The name.
43: * @param choice The choice.
44: * @param sequence The sequence.
45: * @param isBefore The before flag.
46: */
47: public AlternativeAddition(String dType, NonTerminal name,
48: OrderedChoice choice, SequenceName sequence,
49: boolean isBefore) {
50: super (null, dType, name, choice);
51: this .sequence = sequence;
52: this .isBefore = isBefore;
53: }
54:
55: public boolean isAddition() {
56: return true;
57: }
58:
59: public boolean equals(Object o) {
60: if (this == o)
61: return true;
62: if (!(o instanceof AlternativeAddition))
63: return false;
64: AlternativeAddition other = (AlternativeAddition) o;
65: if (!name.equals(other.name))
66: return false;
67: if (null == type) {
68: if (!dType.equals(other.dType))
69: return false;
70: } else {
71: if (!type.equals(other.type))
72: return false;
73: }
74: if (!sequence.equals(other.sequence))
75: return false;
76: return isBefore == other.isBefore;
77: }
78:
79: }
|