-
Notifications
You must be signed in to change notification settings - Fork 0
/
SRAct.java
67 lines (52 loc) · 1.21 KB
/
SRAct.java
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
/*
File: SRAct.java
Author: zerksis d. umrigar (zdu@acm.org)
Copyright (C) 1997 Zerksis D. Umrigar
Last Update Time-stamp: "97/06/27 20:40:24 umrigar"
This code is distributed under the terms of the GNU General Public License.
See the file COPYING with this distribution, or
http://www.fsf.org/copyleft/gpl.html
THERE IS ABSOLUTELY NO WARRANTY FOR THIS PROGRAM.
*/
package zdu.parsdemo;
class SRAct
{
SRAct(int type, Rule rule)
{
this.type = type;
this.stateOrRule = rule;
}
SRAct(int type, SRState state)
{
this.type = type;
this.stateOrRule = state;
}
int getType()
{
return type;
}
SRState getState()
{
return (SRState)stateOrRule;
}
Rule getRule()
{
return (Rule)stateOrRule;
}
public String toString()
{
if (type == REDUCE)
{
return "r" + ((Rule)stateOrRule);
}
else
{
return ((type == SHIFT) ? "s" : "g") + (SRState)(stateOrRule);
}
}
private int type;
private Object stateOrRule;
static final int SHIFT = 0;
static final int REDUCE = SHIFT + 1;
static final int GOTO = REDUCE + 1;
};