97 |
/* Be ready to map a state_number_t to an int. */ |
/* Be ready to map a state_number_t to an int. */ |
98 |
# define state_number_as_int(Tok) ((int) (Tok)) |
# define state_number_as_int(Tok) ((int) (Tok)) |
99 |
|
|
100 |
/*---------. |
/*--------------. |
101 |
| Shifts. | |
| Transitions. | |
102 |
`---------*/ |
`--------------*/ |
103 |
|
|
104 |
typedef struct shifts_s |
typedef struct transtion_s |
105 |
{ |
{ |
106 |
short nshifts; |
short num; |
107 |
state_number_t shifts[1]; |
state_number_t states[1]; |
108 |
} shifts_t; |
} transitions_t; |
109 |
|
|
110 |
|
|
111 |
/* What is the symbol which is shifted by SHIFTS->shifts[Shift]? Can |
/* What is the symbol which is shifted by TRANSITIONS->states[Shift]? Can |
112 |
be a token (amongst which the error token), or non terminals in |
be a token (amongst which the error token), or non terminals in |
113 |
case of gotos. */ |
case of gotos. */ |
114 |
|
|
115 |
#define SHIFT_SYMBOL(Shifts, Shift) \ |
#define TRANSITION_SYMBOL(Transitions, Shift) \ |
116 |
(states[Shifts->shifts[Shift]]->accessing_symbol) |
(states[Transitions->states[Shift]]->accessing_symbol) |
117 |
|
|
118 |
/* Is the SHIFTS->shifts[Shift] a real shift? (as opposed to gotos.) */ |
/* Is the TRANSITIONS->states[Shift] a real shift? (as opposed to gotos.) */ |
119 |
|
|
120 |
#define SHIFT_IS_SHIFT(Shifts, Shift) \ |
#define TRANSITION_IS_SHIFT(Transitions, Shift) \ |
121 |
(ISTOKEN (SHIFT_SYMBOL (Shifts, Shift))) |
(ISTOKEN (TRANSITION_SYMBOL (Transitions, Shift))) |
122 |
|
|
123 |
/* Is the SHIFTS->shifts[Shift] a goto?. */ |
/* Is the TRANSITIONS->states[Shift] a goto?. */ |
124 |
|
|
125 |
#define SHIFT_IS_GOTO(Shifts, Shift) \ |
#define TRANSITION_IS_GOTO(Transitions, Shift) \ |
126 |
(!SHIFT_IS_SHIFT (Shifts, Shift)) |
(!TRANSITION_IS_SHIFT (Transitions, Shift)) |
127 |
|
|
128 |
/* Is the SHIFTS->shifts[Shift] then handling of the error token?. */ |
/* Is the TRANSITIONS->states[Shift] then handling of the error token?. */ |
129 |
|
|
130 |
#define SHIFT_IS_ERROR(Shifts, Shift) \ |
#define TRANSITION_IS_ERROR(Transitions, Shift) \ |
131 |
(SHIFT_SYMBOL (Shifts, Shift) == errtoken->number) |
(TRANSITION_SYMBOL (Transitions, Shift) == errtoken->number) |
132 |
|
|
133 |
/* When resolving a SR conflicts, if the reduction wins, the shift is |
/* When resolving a SR conflicts, if the reduction wins, the shift is |
134 |
disabled. */ |
disabled. */ |
135 |
|
|
136 |
#define SHIFT_DISABLE(Shifts, Shift) \ |
#define TRANSITION_DISABLE(Transitions, Shift) \ |
137 |
(Shifts->shifts[Shift] = 0) |
(Transitions->states[Shift] = 0) |
138 |
|
|
139 |
#define SHIFT_IS_DISABLED(Shifts, Shift) \ |
#define TRANSITION_IS_DISABLED(Transitions, Shift) \ |
140 |
(Shifts->shifts[Shift] == 0) |
(Transitions->states[Shift] == 0) |
141 |
|
|
142 |
/* Return the state such these SHIFTS contain a shift/goto to it on |
/* Return the state such these TRANSITIONS contain a shift/goto to it on |
143 |
SYMBOL. Aborts if none found. */ |
SYMBOL. Aborts if none found. */ |
144 |
struct state_s; |
struct state_s; |
145 |
struct state_s *shifts_to PARAMS ((shifts_t *shifts, symbol_number_t s)); |
struct state_s *transitions_to PARAMS ((transitions_t *state, |
146 |
|
symbol_number_t s)); |
147 |
|
|
148 |
|
|
149 |
/*-------. |
/*-------. |
150 |
| Errs. | |
| Errs. | |
180 |
{ |
{ |
181 |
state_number_t number; |
state_number_t number; |
182 |
symbol_number_t accessing_symbol; |
symbol_number_t accessing_symbol; |
183 |
shifts_t *shifts; |
transitions_t *shifts; |
184 |
reductions_t *reductions; |
reductions_t *reductions; |
185 |
errs_t *errs; |
errs_t *errs; |
186 |
|
|
216 |
size_t core_size, item_number_t *core)); |
size_t core_size, item_number_t *core)); |
217 |
|
|
218 |
/* Set the shifts of STATE. */ |
/* Set the shifts of STATE. */ |
219 |
void state_shifts_set PARAMS ((state_t *state, |
void state_transitions_set PARAMS ((state_t *state, |
220 |
int nshifts, state_number_t *shifts)); |
int nshifts, state_number_t *shifts)); |
221 |
|
|
222 |
/* Set the reductions of STATE. */ |
/* Set the reductions of STATE. */ |