version 1.6, 2001/07/16 06:29:44 |
version 1.7, 2001/11/19 19:02:18 |
|
|
void |
void |
make_parser() |
make_parser() |
{ |
{ |
register int i; |
int i; |
|
|
parser = NEW2(nstates, action *); |
parser = NEW2(nstates, action *); |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
|
|
|
|
action * |
action * |
parse_actions(stateno) |
parse_actions(stateno) |
register int stateno; |
int stateno; |
{ |
{ |
register action *actions; |
action *actions; |
|
|
actions = get_shifts(stateno); |
actions = get_shifts(stateno); |
actions = add_reductions(stateno, actions); |
actions = add_reductions(stateno, actions); |
|
|
get_shifts(stateno) |
get_shifts(stateno) |
int stateno; |
int stateno; |
{ |
{ |
register action *actions, *temp; |
action *actions, *temp; |
register shifts *sp; |
shifts *sp; |
register short *to_state; |
short *to_state; |
register int i, k; |
int i, k; |
register int symbol; |
int symbol; |
|
|
actions = 0; |
actions = 0; |
sp = shift_table[stateno]; |
sp = shift_table[stateno]; |
|
|
action * |
action * |
add_reductions(stateno, actions) |
add_reductions(stateno, actions) |
int stateno; |
int stateno; |
register action *actions; |
action *actions; |
{ |
{ |
register int i, j, m, n; |
int i, j, m, n; |
register int ruleno, tokensetsize; |
int ruleno, tokensetsize; |
register unsigned *rowp; |
unsigned *rowp; |
|
|
tokensetsize = WORDSIZE(ntokens); |
tokensetsize = WORDSIZE(ntokens); |
m = lookaheads[stateno]; |
m = lookaheads[stateno]; |
|
|
|
|
action * |
action * |
add_reduce(actions, ruleno, symbol) |
add_reduce(actions, ruleno, symbol) |
register action *actions; |
action *actions; |
register int ruleno, symbol; |
int ruleno, symbol; |
{ |
{ |
register action *temp, *prev, *next; |
action *temp, *prev, *next; |
|
|
prev = 0; |
prev = 0; |
for (next = actions; next && next->symbol < symbol; next = next->next) |
for (next = actions; next && next->symbol < symbol; next = next->next) |
|
|
void |
void |
find_final_state() |
find_final_state() |
{ |
{ |
register int goal, i; |
int goal, i; |
register short *to_state; |
short *to_state; |
register shifts *p; |
shifts *p; |
|
|
p = shift_table[0]; |
p = shift_table[0]; |
to_state = p->shift; |
to_state = p->shift; |
|
|
void |
void |
unused_rules() |
unused_rules() |
{ |
{ |
register int i; |
int i; |
register action *p; |
action *p; |
|
|
rules_used = (short *) MALLOC(nrules*sizeof(short)); |
rules_used = (short *) MALLOC(nrules*sizeof(short)); |
if (rules_used == 0) no_space(); |
if (rules_used == 0) no_space(); |
|
|
void |
void |
remove_conflicts() |
remove_conflicts() |
{ |
{ |
register int i; |
int i; |
register int symbol; |
int symbol; |
register action *p, *pref; |
action *p, *pref; |
|
|
SRtotal = 0; |
SRtotal = 0; |
RRtotal = 0; |
RRtotal = 0; |
|
|
sole_reduction(stateno) |
sole_reduction(stateno) |
int stateno; |
int stateno; |
{ |
{ |
register int count, ruleno; |
int count, ruleno; |
register action *p; |
action *p; |
|
|
count = 0; |
count = 0; |
ruleno = 0; |
ruleno = 0; |
|
|
void |
void |
defreds() |
defreds() |
{ |
{ |
register int i; |
int i; |
|
|
defred = NEW2(nstates, short); |
defred = NEW2(nstates, short); |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
|
|
|
|
void |
void |
free_action_row(p) |
free_action_row(p) |
register action *p; |
action *p; |
{ |
{ |
register action *q; |
action *q; |
|
|
while (p) |
while (p) |
{ |
{ |
|
|
void |
void |
free_parser() |
free_parser() |
{ |
{ |
register int i; |
int i; |
|
|
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
free_action_row(parser[i]); |
free_action_row(parser[i]); |