-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsymbol_part.cs
126 lines (106 loc) · 3.58 KB
/
symbol_part.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
namespace CUP
{
using System;
/// <summary>This class represents a part of a production which is a symbol (terminal
/// or non terminal). This simply maintains a reference to the symbol in
/// question.
/// *
/// </summary>
/// <seealso cref=" CUP.production
/// "/>
/// <version> last updated: 11/25/95
/// </version>
/// <author> Scott Hudson
///
/// </author>
public class symbol_part:production_part
{
/*-----------------------------------------------------------*/
/*--- Constructor(s) ----------------------------------------*/
/*-----------------------------------------------------------*/
/// <summary>Full constructor.
/// </summary>
/// <param name="sym">the symbol that this part is made up of.
/// </param>
/// <param name="lab">an optional label string for the part.
///
/// </param>
public symbol_part(symbol sym, string lab):base(lab)
{
if (sym == null)
throw new internal_error("Attempt to construct a symbol_part with a null symbol");
_the_symbol = sym;
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Constructor with no label.
/// </summary>
/// <param name="sym">the symbol that this part is made up of.
///
/// </param>
public symbol_part(symbol sym):this(sym, null)
{
}
/*-----------------------------------------------------------*/
/*--- (Access to) Instance Variables ------------------------*/
/*-----------------------------------------------------------*/
/// <summary>The symbol that this part is made up of.
/// </summary>
protected symbol _the_symbol;
/// <summary>The symbol that this part is made up of.
/// </summary>
public virtual symbol the_symbol()
{
return _the_symbol;
}
/*-----------------------------------------------------------*/
/*--- General Methods ---------------------------------------*/
/*-----------------------------------------------------------*/
/// <summary>Respond that we are not an action part.
/// </summary>
public override bool is_action()
{
return false;
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Equality comparison.
/// </summary>
public virtual bool equals(symbol_part other)
{
return other != null && base.equals(other) && the_symbol().Equals(other.the_symbol());
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Generic equality comparison.
/// </summary>
public override bool Equals(object other)
{
if (!(other is symbol_part))
return false;
else
return equals((symbol_part) other);
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Produce a hash code.
/// </summary>
public override int GetHashCode()
{
return base.GetHashCode() ^ (the_symbol() == null?0:the_symbol().GetHashCode());
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Convert to a string.
/// </summary>
public override string ToString()
{
if (the_symbol() != null)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1043"'
return base.ToString() + the_symbol();
}
else
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1043"'
return base.ToString() + "$$MISSING-SYMBOL$$";
}
}
/*-----------------------------------------------------------*/
}
}