01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2004-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: /**
24: * Element to set the semantic value to a list of {@link
25: * xtc.util.Action actions}. This element sets the semantic value to
26: * a pair, whose value is an action that produces a generic node. The
27: * generic node's children are a production's component expressions,
28: * with the action's argument being the first child.
29: *
30: * @author Robert Grimm
31: * @version $Revision: 1.10 $
32: */
33: public class GenericRecursionValue extends GenericActionValue {
34:
35: /** The binding for the variable referencing the next pair. */
36: public final Binding list;
37:
38: /**
39: * Create a new generic recursion value.
40: *
41: * @param name The name of the generic node.
42: * @param first The action's argument.
43: * @param children The list of children.
44: * @param formatting The list of bindings for formatting.
45: * @param list The binding for the list.
46: */
47: public GenericRecursionValue(String name, String first,
48: List<Binding> children, List<Binding> formatting,
49: Binding list) {
50: super (name, first, children, formatting);
51: this .list = list;
52: }
53:
54: public Tag tag() {
55: return Tag.GENERIC_RECURSION_VALUE;
56: }
57:
58: public int hashCode() {
59: return name.hashCode();
60: }
61:
62: public boolean equals(Object o) {
63: if (this == o)
64: return true;
65: if (!(o instanceof GenericRecursionValue))
66: return false;
67: GenericRecursionValue other = (GenericRecursionValue) o;
68: if (!name.equals(other.name))
69: return false;
70: if (!first.equals(other.first))
71: return false;
72: if (!list.equals(other.list))
73: return false;
74: if (!children.equals(other.children))
75: return false;
76: return formatting.equals(other.formatting);
77: }
78:
79: }
|