1 modulegamma.parsgen.lalr1.CanonicalLR1Tables;
2 3 importgamma.grammar.Alternative;
4 importgamma.grammar.Nonterminal;
5 importgamma.grammar.Terminal;
6 7 /**
8 * Abstract view on the parse tables for a deterministic canonical
9 * LR-like parser with 1-symbol lookahead. Note that the represented
10 * parser may well be a <emph>nondeterministic</emph> one.
11 *
12 * @author SöKa
13 */14 publicinterfaceCanonicalLR1Tables15 {
16 publicabstractclassAction17 {
18 publicTerminallookahead;
19 20 publicthis(Terminallookahead)
21 {
22 this.lookahead = lookahead;
23 }
24 }
25 26 publicclassShift : Action27 {
28 publicintstate; // LRMachine.State.index()29 30 publicthis(Terminallookahead, intstate)
31 {
32 super(lookahead);
33 this.state = state;
34 }
35 }
36 37 publicclassHalt : Action38 {
39 publicthis(Terminallookahead)
40 {
41 super(lookahead);
42 }
43 }
44 45 publicclassReduce : Action46 {
47 publicAlternativealternative;
48 49 publicthis(Terminallookahead, Alternativealternative)
50 {
51 super(lookahead);
52 this.alternative = alternative;
53 }
54 }
55 56 publicclassGoto57 {
58 publicNonterminallhs;
59 60 publicintstate; // LRMachine.State.index()61 62 publicthis(Nonterminallhs, intstate)
63 {
64 this.lhs = lhs;
65 this.state = state;
66 }
67 }
68 69 /**
70 * Returns the number of states in the parser.
71 */72 intstateCount();
73 74 /**
75 * Returns the end-of-file Terminal symbol that has been added to
76 * the original grammar to generate the parser.
77 */78 Terminaleof();
79 80 /**
81 * Returns a List of the Shift, Halt, and Reduce entries for the given
82 * state's "parser action table" row. Entries are guaranteed to be
83 * sorted by the List entries' lookahead.index().
84 * <p>
85 * Implementation must be such that this method can safely be called
86 * multiple times for a fixed <code>state</code> without performance
87 * becoming an issue.
88 */89 Action[] getSortedParserActionRow(intstate);
90 91 /**
92 * Returns a List of the Goto entries for the given state's "goto table"
93 * row. Entries are guaranteed to be sorted by the List entries'
94 * lhs.index().
95 * <p>
96 * Implementation must be such that this method can safely be called
97 * multiple times for a fixed <code>state</code> without performance
98 * becoming an issue.
99 */100 Goto[] getSortedGotoRow(intstate);
101 }