-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse_action.cs
115 lines (92 loc) · 3.09 KB
/
parse_action.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
namespace CUP
{
using System;
/// <summary>This class serves as the base class for entries in a parse action table.
/// Full entries will either be SHIFT(state_num), REDUCE(production), NONASSOC,
/// or ERROR. Objects of this base class will default to ERROR, while
/// the other three types will be represented by subclasses.
///
/// </summary>
/// <seealso cref=" CUP.reduce_action
/// "/>
/// <seealso cref=" CUP.shift_action
/// "/>
/// <version> last updated: 7/2/96
/// </version>
/// <author> Frank Flannery
///
/// </author>
public class parse_action
{
/*-----------------------------------------------------------*/
/*--- Constructor(s) ----------------------------------------*/
/*-----------------------------------------------------------*/
/// <summary>Simple constructor.
/// </summary>
public parse_action()
{
/* nothing to do in the base class */
}
/*-----------------------------------------------------------*/
/*--- (Access to) Static (Class) Variables ------------------*/
/*-----------------------------------------------------------*/
/// <summary>Constant for action type -- error action.
/// </summary>
public const int ERROR = 0;
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Constant for action type -- shift action.
/// </summary>
public const int SHIFT = 1;
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Constants for action type -- reduce action.
/// </summary>
public const int REDUCE = 2;
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Constants for action type -- reduce action.
/// </summary>
public const int NONASSOC = 3;
/*-----------------------------------------------------------*/
/*--- General Methods ---------------------------------------*/
/*-----------------------------------------------------------*/
/// <summary>Quick access to the type -- base class defaults to error.
/// </summary>
public virtual int kind()
{
return ERROR;
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Equality test.
/// </summary>
public virtual bool equals(parse_action other)
{
/* we match all error actions */
return other != null && other.kind() == ERROR;
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Generic equality test.
/// </summary>
public override bool Equals(object other)
{
if (other is parse_action)
return equals((parse_action) other);
else
return false;
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Compute a hash code.
/// </summary>
public override int GetHashCode()
{
/* all objects of this class hash together */
return 0xCafe123;
}
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
/// <summary>Convert to string.
/// </summary>
public override string ToString()
{
return "ERROR";
}
/*-----------------------------------------------------------*/
}
}