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: import java.util.List;
22:
23: import xtc.tree.Attribute;
24:
25: import xtc.type.Type;
26:
27: /**
28: * A complete production.
29: *
30: * @author Robert Grimm
31: * @version $Revision: 1.8 $
32: */
33: public class FullProduction extends Production {
34:
35: /**
36: * Create a new full production. Note that the {@link #qName
37: * qualified name} needs to be initialized separately.
38: *
39: * @param attributes The list of attributes.
40: * @param dType The declared type.
41: * @param name The name.
42: * @param choice The choice.
43: */
44: public FullProduction(List<Attribute> attributes, String dType,
45: NonTerminal name, OrderedChoice choice) {
46: super (attributes, dType, name, null, choice);
47: }
48:
49: /**
50: * Create a new full production. Note that the {@link #qName
51: * qualified name} needs to be initialized separately.
52: *
53: * @param attributes The list of attributes.
54: * @param type The actual type.
55: * @param name The name.
56: * @param qName The fully qualified name.
57: * @param choice The choice.
58: */
59: public FullProduction(List<Attribute> attributes, Type type,
60: NonTerminal name, NonTerminal qName, OrderedChoice choice) {
61: super (attributes, type, name, qName, choice);
62: }
63:
64: public boolean equals(Object o) {
65: if (this == o)
66: return true;
67: if (!(o instanceof FullProduction))
68: return false;
69: FullProduction other = (FullProduction) o;
70: if (!name.equals(other.name))
71: return false;
72: if (null == qName) {
73: if (qName != other.qName)
74: return false;
75: } else {
76: if (!qName.equals(other.qName))
77: return false;
78: }
79: if (null == type) {
80: if (!dType.equals(other.dType))
81: return false;
82: } else {
83: if (!type.equals(other.type))
84: return false;
85: }
86: if (!choice.equals(other.choice))
87: return false;
88: return Attribute.areEquivalent(attributes, other.attributes);
89: }
90:
91: public boolean isFull() {
92: return true;
93: }
94:
95: }
|