Berkeley YACC  1993-03-03
Berkeley's version of Yet Another Compiler Compiler
 All Data Structures Files Functions Variables Typedefs Macros Groups
lalr.c File Reference
#include "defs.h"
+ Include dependency graph for lalr.c:

Go to the source code of this file.

Data Structures

struct  shorts
 

Typedefs

typedef struct shorts shorts
 

Functions

short ** transpose ()
 
 lalr ()
 
 set_state_table ()
 
 set_accessing_symbol ()
 
 set_shift_table ()
 
 set_reduction_table ()
 
 set_maxrhs ()
 
 initialize_LA ()
 
 set_goto_map ()
 
int map_goto (int state, int symbol)
 
 initialize_F ()
 
 build_relations ()
 
 add_lookback_edge (int stateno, int ruleno, int gotono)
 
short ** transpose (short **R, int n)
 
 compute_FOLLOWS ()
 
 compute_lookaheads ()
 
 digraph (short **relation)
 
 traverse (int i)
 

Variables

int tokensetsize
 
short * lookaheads
 
short * LAruleno
 
unsigned * LA
 
short * accessing_symbol
 
core ** state_table
 
shifts ** shift_table
 
reductions ** reduction_table
 
short * goto_map
 
short * from_state
 
short * to_state
 
static int infinity
 
static int maxrhs
 
static int ngotos
 
static unsigned * F
 
static short ** includes
 
static shorts ** lookback
 
static short ** R
 
static short * INDEX
 
static short * VERTICES
 
static int top
 

Typedef Documentation

typedef struct shorts shorts

Function Documentation

add_lookback_edge ( int  stateno,
int  ruleno,
int  gotono 
)

Definition at line 432 of file lalr.c.

References LAruleno, lookaheads, NEW, shorts::next, and shorts::value.

Referenced by build_relations().

434 {
435  register int i, k;
436  register int found;
437  register shorts *sp;
438 
439  i = lookaheads[stateno];
440  k = lookaheads[stateno + 1];
441  found = 0;
442  while (!found && i < k)
443  {
444  if (LAruleno[i] == ruleno)
445  found = 1;
446  else
447  ++i;
448  }
449  assert(found);
450 
451  sp = NEW(shorts);
452  sp->next = lookback[i];
453  sp->value = gotono;
454  lookback[i] = sp;
455 }
short * LAruleno
Definition: lalr.c:13
struct shorts * next
Definition: lalr.c:6
static shorts ** lookback
Definition: lalr.c:30
short value
Definition: lalr.c:7
Definition: lalr.c:3
short * lookaheads
Definition: lalr.c:12
#define NEW(t)
Definition: defs.h:104

+ Here is the caller graph for this function:

build_relations ( )

Definition at line 340 of file lalr.c.

References accessing_symbol, add_lookback_edge(), derives, done(), FREE, from_state, includes, ISVAR, map_goto(), maxrhs, NEW2, ngotos, shifts::nshifts, nullable, ritem, rrhs, shifts::shift, to_state, and transpose().

Referenced by lalr().

341 {
342  register int i;
343  register int j;
344  register int k;
345  register short *rulep;
346  register short *rp;
347  register shifts *sp;
348  register int length;
349  register int nedges;
350  register int done;
351  register int state1;
352  register int stateno;
353  register int symbol1;
354  register int symbol2;
355  register short *shortp;
356  register short *edge;
357  register short *states;
358  register short **new_includes;
359 
360  includes = NEW2(ngotos, short *);
361  edge = NEW2(ngotos + 1, short);
362  states = NEW2(maxrhs + 1, short);
363 
364  for (i = 0; i < ngotos; i++)
365  {
366  nedges = 0;
367  state1 = from_state[i];
368  symbol1 = accessing_symbol[to_state[i]];
369 
370  for (rulep = derives[symbol1]; *rulep >= 0; rulep++)
371  {
372  length = 1;
373  states[0] = state1;
374  stateno = state1;
375 
376  for (rp = ritem + rrhs[*rulep]; *rp >= 0; rp++)
377  {
378  symbol2 = *rp;
379  sp = shift_table[stateno];
380  k = sp->nshifts;
381 
382  for (j = 0; j < k; j++)
383  {
384  stateno = sp->shift[j];
385  if (accessing_symbol[stateno] == symbol2) break;
386  }
387 
388  states[length++] = stateno;
389  }
390 
391  add_lookback_edge(stateno, *rulep, i);
392 
393  length--;
394  done = 0;
395  while (!done)
396  {
397  done = 1;
398  rp--;
399  if (ISVAR(*rp))
400  {
401  stateno = states[--length];
402  edge[nedges++] = map_goto(stateno, *rp);
403  if (nullable[*rp] && length > 0) done = 0;
404  }
405  }
406  }
407 
408  if (nedges)
409  {
410  includes[i] = shortp = NEW2(nedges + 1, short);
411  for (j = 0; j < nedges; j++)
412  shortp[j] = edge[j];
413  shortp[nedges] = -1;
414  }
415  }
416 
417  new_includes = transpose(includes, ngotos);
418 
419  for (i = 0; i < ngotos; i++)
420  if (includes[i])
421  FREE(includes[i]);
422 
423  FREE(includes);
424 
425  includes = new_includes;
426 
427  FREE(edge);
428  FREE(states);
429 }
short * to_state
Definition: lalr.c:21
add_lookback_edge(int stateno, int ruleno, int gotono)
Definition: lalr.c:432
short shift[1]
Definition: defs.h:148
#define NEW2(n, t)
Definition: defs.h:105
Definition: defs.h:143
short * accessing_symbol
Definition: lalr.c:15
static int ngotos
Definition: lalr.c:27
#define ISVAR(s)
Definition: defs.h:96
static short ** includes
Definition: lalr.c:29
done(int k)
Shutdown function.
Definition: main.c:156
int map_goto(int state, int symbol)
Definition: lalr.c:235
static int maxrhs
Definition: lalr.c:26
short nshifts
Definition: defs.h:147
char * nullable
Definition: main.c:141
short * from_state
Definition: lalr.c:20
short * rrhs
List of right-hand sides of all rules.
Definition: main.c:126
#define FREE(x)
Definition: defs.h:102
short * ritem
Representation of all productions (and items)
Definition: main.c:112
short ** derives
List of rules that derive each non-terminal.
Definition: main.c:140
short ** transpose()
shifts ** shift_table
Definition: lalr.c:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

compute_FOLLOWS ( )

Definition at line 517 of file lalr.c.

References digraph(), and includes.

Referenced by lalr().

518 {
519  digraph(includes);
520 }
static short ** includes
Definition: lalr.c:29
digraph(short **relation)
Definition: lalr.c:557

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

compute_lookaheads ( )

Definition at line 523 of file lalr.c.

References F, FREE, LA, lookaheads, shorts::next, nstates, tokensetsize, and shorts::value.

Referenced by lalr().

524 {
525  register int i, n;
526  register unsigned *fp1, *fp2, *fp3;
527  register shorts *sp, *next;
528  register unsigned *rowp;
529 
530  rowp = LA;
531  n = lookaheads[nstates];
532  for (i = 0; i < n; i++)
533  {
534  fp3 = rowp + tokensetsize;
535  for (sp = lookback[i]; sp; sp = sp->next)
536  {
537  fp1 = rowp;
538  fp2 = F + tokensetsize * sp->value;
539  while (fp1 < fp3)
540  *fp1++ |= *fp2++;
541  }
542  rowp = fp3;
543  }
544 
545  for (i = 0; i < n; i++)
546  for (sp = lookback[i]; sp; sp = next)
547  {
548  next = sp->next;
549  FREE(sp);
550  }
551 
552  FREE(lookback);
553  FREE(F);
554 }
int nstates
Definition: lr0.c:8
struct shorts * next
Definition: lalr.c:6
static shorts ** lookback
Definition: lalr.c:30
short value
Definition: lalr.c:7
Definition: lalr.c:3
static unsigned * F
Definition: lalr.c:28
int tokensetsize
Definition: lalr.c:11
#define FREE(x)
Definition: defs.h:102
unsigned * LA
Definition: lalr.c:14
short * lookaheads
Definition: lalr.c:12

+ Here is the caller graph for this function:

digraph ( short **  relation)

Definition at line 557 of file lalr.c.

References FREE, INDEX, infinity, NEW2, ngotos, R, top, traverse(), and VERTICES.

Referenced by compute_FOLLOWS(), and initialize_F().

559 {
560  register int i;
561 
562  infinity = ngotos + 2;
563  INDEX = NEW2(ngotos + 1, short);
564  VERTICES = NEW2(ngotos + 1, short);
565  top = 0;
566 
567  R = relation;
568 
569  for (i = 0; i < ngotos; i++)
570  INDEX[i] = 0;
571 
572  for (i = 0; i < ngotos; i++)
573  {
574  if (INDEX[i] == 0 && R[i])
575  traverse(i);
576  }
577 
578  FREE(INDEX);
579  FREE(VERTICES);
580 }
#define NEW2(n, t)
Definition: defs.h:105
static short * VERTICES
Definition: lalr.c:33
static short * INDEX
Definition: lalr.c:32
static int ngotos
Definition: lalr.c:27
static int infinity
Definition: lalr.c:25
static int top
Definition: lalr.c:34
#define FREE(x)
Definition: defs.h:102
static short ** R
Definition: lalr.c:31
traverse(int i)
Definition: lalr.c:584

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

initialize_F ( )

Definition at line 263 of file lalr.c.

References accessing_symbol, digraph(), F, FREE, ISVAR, map_goto(), NEW2, ngotos, shifts::nshifts, nullable, SETBIT, shifts::shift, to_state, and tokensetsize.

Referenced by lalr().

264 {
265  register int i;
266  register int j;
267  register int k;
268  register shifts *sp;
269  register short *edge;
270  register unsigned *rowp;
271  register short *rp;
272  register short **reads;
273  register int nedges;
274  register int stateno;
275  register int symbol;
276  register int nwords;
277 
278  nwords = ngotos * tokensetsize;
279  F = NEW2(nwords, unsigned);
280 
281  reads = NEW2(ngotos, short *);
282  edge = NEW2(ngotos + 1, short);
283  nedges = 0;
284 
285  rowp = F;
286  for (i = 0; i < ngotos; i++)
287  {
288  stateno = to_state[i];
289  sp = shift_table[stateno];
290 
291  if (sp)
292  {
293  k = sp->nshifts;
294 
295  for (j = 0; j < k; j++)
296  {
297  symbol = accessing_symbol[sp->shift[j]];
298  if (ISVAR(symbol))
299  break;
300  SETBIT(rowp, symbol);
301  }
302 
303  for (; j < k; j++)
304  {
305  symbol = accessing_symbol[sp->shift[j]];
306  if (nullable[symbol])
307  edge[nedges++] = map_goto(stateno, symbol);
308  }
309 
310  if (nedges)
311  {
312  reads[i] = rp = NEW2(nedges + 1, short);
313 
314  for (j = 0; j < nedges; j++)
315  rp[j] = edge[j];
316 
317  rp[nedges] = -1;
318  nedges = 0;
319  }
320  }
321 
322  rowp += tokensetsize;
323  }
324 
325  SETBIT(F, 0);
326  digraph(reads);
327 
328  for (i = 0; i < ngotos; i++)
329  {
330  if (reads[i])
331  FREE(reads[i]);
332  }
333 
334  FREE(reads);
335  FREE(edge);
336 }
short * to_state
Definition: lalr.c:21
short shift[1]
Definition: defs.h:148
#define NEW2(n, t)
Definition: defs.h:105
Definition: defs.h:143
short * accessing_symbol
Definition: lalr.c:15
static int ngotos
Definition: lalr.c:27
#define ISVAR(s)
Definition: defs.h:96
int map_goto(int state, int symbol)
Definition: lalr.c:235
short nshifts
Definition: defs.h:147
char * nullable
Definition: main.c:141
digraph(short **relation)
Definition: lalr.c:557
static unsigned * F
Definition: lalr.c:28
int tokensetsize
Definition: lalr.c:11
#define FREE(x)
Definition: defs.h:102
#define SETBIT(r, n)
Definition: defs.h:28
shifts ** shift_table
Definition: lalr.c:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

initialize_LA ( )

Definition at line 128 of file lalr.c.

References LA, LAruleno, lookaheads, NEW2, reductions::nreds, nstates, reductions::rules, and tokensetsize.

Referenced by lalr().

129 {
130  register int i, j, k;
131  register reductions *rp;
132 
133  lookaheads = NEW2(nstates + 1, short);
134 
135  k = 0;
136  for (i = 0; i < nstates; i++)
137  {
138  lookaheads[i] = k;
139  rp = reduction_table[i];
140  if (rp)
141  k += rp->nreds;
142  }
143  lookaheads[nstates] = k;
144 
145  LA = NEW2(k * tokensetsize, unsigned);
146  LAruleno = NEW2(k, short);
147  lookback = NEW2(k, shorts *);
148 
149  k = 0;
150  for (i = 0; i < nstates; i++)
151  {
152  rp = reduction_table[i];
153  if (rp)
154  {
155  for (j = 0; j < rp->nreds; j++)
156  {
157  LAruleno[k] = rp->rules[j];
158  k++;
159  }
160  }
161  }
162 }
reductions ** reduction_table
Definition: lalr.c:18
short * LAruleno
Definition: lalr.c:13
short rules[1]
Definition: defs.h:160
#define NEW2(n, t)
Definition: defs.h:105
int nstates
Definition: lr0.c:8
static shorts ** lookback
Definition: lalr.c:30
Definition: lalr.c:3
int tokensetsize
Definition: lalr.c:11
short nreds
Definition: defs.h:159
unsigned * LA
Definition: lalr.c:14
short * lookaheads
Definition: lalr.c:12

+ Here is the caller graph for this function:

lalr ( )

Definition at line 37 of file lalr.c.

References build_relations(), compute_FOLLOWS(), compute_lookaheads(), initialize_F(), initialize_LA(), ntokens, set_accessing_symbol(), set_goto_map(), set_maxrhs(), set_reduction_table(), set_shift_table(), set_state_table(), tokensetsize, and WORDSIZE.

Referenced by main().

38 {
40 
45  set_maxrhs();
46  initialize_LA();
47  set_goto_map();
48  initialize_F();
52 }
compute_lookaheads()
Definition: lalr.c:523
set_goto_map()
Definition: lalr.c:165
int ntokens
The number of tokens (terminals) in the grammar.
Definition: main.c:64
compute_FOLLOWS()
Definition: lalr.c:517
set_maxrhs()
Definition: lalr.c:100
#define WORDSIZE(n)
Definition: defs.h:26
build_relations()
Definition: lalr.c:340
initialize_LA()
Definition: lalr.c:128
set_state_table()
Definition: lalr.c:56
set_accessing_symbol()
Definition: lalr.c:67
set_reduction_table()
Definition: lalr.c:89
int tokensetsize
Definition: lalr.c:11
set_shift_table()
Definition: lalr.c:78
initialize_F()
Definition: lalr.c:263

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_goto ( int  state,
int  symbol 
)

Definition at line 235 of file lalr.c.

References from_state, goto_map, and high.

Referenced by build_relations(), and initialize_F().

238 {
239  register int high;
240  register int low;
241  register int middle;
242  register int s;
243 
244  low = goto_map[symbol];
245  high = goto_map[symbol + 1];
246 
247  for (;;)
248  {
249  assert(low <= high);
250  middle = (low + high) >> 1;
251  s = from_state[middle];
252  if (s == state)
253  return (middle);
254  else if (s < state)
255  low = middle + 1;
256  else
257  high = middle - 1;
258  }
259 }
short * goto_map
Definition: lalr.c:19
short * from_state
Definition: lalr.c:20
static int high
Definition: output.c:17

+ Here is the caller graph for this function:

set_accessing_symbol ( )

Definition at line 67 of file lalr.c.

References accessing_symbol, core::accessing_symbol, first_state, NEW2, core::next, nstates, and core::number.

Referenced by lalr().

68 {
69  register core *sp;
70 
71  accessing_symbol = NEW2(nstates, short);
72  for (sp = first_state; sp; sp = sp->next)
74 }
#define NEW2(n, t)
Definition: defs.h:105
struct core * next
Definition: defs.h:131
core * first_state
Definition: lr0.c:9
short * accessing_symbol
Definition: lalr.c:15
int nstates
Definition: lr0.c:8
Definition: defs.h:129
short accessing_symbol
Definition: defs.h:134
short number
Definition: defs.h:133

+ Here is the caller graph for this function:

set_goto_map ( )

Definition at line 165 of file lalr.c.

References accessing_symbol, fatal(), first_shift, FREE, from_state, goto_map, ISTOKEN, MAXSHORT, NEW2, shifts::next, ngotos, shifts::nshifts, nsyms, ntokens, shifts::number, nvars, shifts::shift, and to_state.

Referenced by lalr().

166 {
167  register shifts *sp;
168  register int i;
169  register int symbol;
170  register int k;
171  register short *temp_map;
172  register int state2;
173  register int state1;
174 
175  goto_map = NEW2(nvars + 1, short) - ntokens;
176  temp_map = NEW2(nvars + 1, short) - ntokens;
177 
178  ngotos = 0;
179  for (sp = first_shift; sp; sp = sp->next)
180  {
181  for (i = sp->nshifts - 1; i >= 0; i--)
182  {
183  symbol = accessing_symbol[sp->shift[i]];
184 
185  if (ISTOKEN(symbol)) break;
186 
187  if (ngotos == MAXSHORT)
188  fatal("too many gotos");
189 
190  ngotos++;
191  goto_map[symbol]++;
192  }
193  }
194 
195  k = 0;
196  for (i = ntokens; i < nsyms; i++)
197  {
198  temp_map[i] = k;
199  k += goto_map[i];
200  }
201 
202  for (i = ntokens; i < nsyms; i++)
203  goto_map[i] = temp_map[i];
204 
205  goto_map[nsyms] = ngotos;
206  temp_map[nsyms] = ngotos;
207 
208  from_state = NEW2(ngotos, short);
209  to_state = NEW2(ngotos, short);
210 
211  for (sp = first_shift; sp; sp = sp->next)
212  {
213  state1 = sp->number;
214  for (i = sp->nshifts - 1; i >= 0; i--)
215  {
216  state2 = sp->shift[i];
217  symbol = accessing_symbol[state2];
218 
219  if (ISTOKEN(symbol)) break;
220 
221  k = temp_map[symbol]++;
222  from_state[k] = state1;
223  to_state[k] = state2;
224  }
225  }
226 
227  FREE(temp_map + ntokens);
228 }
short * to_state
Definition: lalr.c:21
short shift[1]
Definition: defs.h:148
#define NEW2(n, t)
Definition: defs.h:105
Definition: defs.h:143
short * goto_map
Definition: lalr.c:19
int ntokens
The number of tokens (terminals) in the grammar.
Definition: main.c:64
short * accessing_symbol
Definition: lalr.c:15
static int ngotos
Definition: lalr.c:27
struct shifts * next
Definition: defs.h:145
shifts * first_shift
Definition: lr0.c:10
#define MAXSHORT
Definition: defs.h:22
short nshifts
Definition: defs.h:147
short * from_state
Definition: lalr.c:20
int nvars
The number of variables (non-terminals) in the grammar.
Definition: main.c:74
#define ISTOKEN(s)
Definition: defs.h:95
int nsyms
The number of symbols (terminals + non-terminals) in the grammar.
Definition: main.c:55
#define FREE(x)
Definition: defs.h:102
fatal(char *msg)
Definition: error.c:19
short number
Definition: defs.h:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

set_maxrhs ( )

Definition at line 100 of file lalr.c.

References maxrhs, nitems, and ritem.

Referenced by lalr().

101 {
102  register short *itemp;
103  register short *item_end;
104  register int length;
105  register int max;
106 
107  length = 0;
108  max = 0;
109  item_end = ritem + nitems;
110  for (itemp = ritem; itemp < item_end; itemp++)
111  {
112  if (*itemp >= 0)
113  {
114  length++;
115  }
116  else
117  {
118  if (length > max) max = length;
119  length = 0;
120  }
121  }
122 
123  maxrhs = max;
124 }
int nitems
Definition: main.c:40
static int maxrhs
Definition: lalr.c:26
short * ritem
Representation of all productions (and items)
Definition: main.c:112

+ Here is the caller graph for this function:

set_reduction_table ( )

Definition at line 89 of file lalr.c.

References first_reduction, NEW2, reductions::next, nstates, and reductions::number.

Referenced by lalr().

90 {
91  register reductions *rp;
92 
94  for (rp = first_reduction; rp; rp = rp->next)
95  reduction_table[rp->number] = rp;
96 }
reductions ** reduction_table
Definition: lalr.c:18
struct reductions * next
Definition: defs.h:157
#define NEW2(n, t)
Definition: defs.h:105
int nstates
Definition: lr0.c:8
short number
Definition: defs.h:158
reductions * first_reduction
Definition: lr0.c:11

+ Here is the caller graph for this function:

set_shift_table ( )

Definition at line 78 of file lalr.c.

References first_shift, NEW2, shifts::next, nstates, and shifts::number.

Referenced by lalr().

79 {
80  register shifts *sp;
81 
83  for (sp = first_shift; sp; sp = sp->next)
84  shift_table[sp->number] = sp;
85 }
#define NEW2(n, t)
Definition: defs.h:105
Definition: defs.h:143
int nstates
Definition: lr0.c:8
struct shifts * next
Definition: defs.h:145
shifts * first_shift
Definition: lr0.c:10
shifts ** shift_table
Definition: lalr.c:17
short number
Definition: defs.h:146

+ Here is the caller graph for this function:

set_state_table ( )

Definition at line 56 of file lalr.c.

References first_state, NEW2, core::next, nstates, and core::number.

Referenced by lalr().

57 {
58  register core *sp;
59 
61  for (sp = first_state; sp; sp = sp->next)
62  state_table[sp->number] = sp;
63 }
core ** state_table
Definition: lalr.c:16
#define NEW2(n, t)
Definition: defs.h:105
struct core * next
Definition: defs.h:131
core * first_state
Definition: lr0.c:9
int nstates
Definition: lr0.c:8
Definition: defs.h:129
short number
Definition: defs.h:133

+ Here is the caller graph for this function:

short** transpose ( )

Referenced by build_relations().

+ Here is the caller graph for this function:

short** transpose ( short **  R,
int  n 
)

Definition at line 460 of file lalr.c.

References FREE, and NEW2.

463 {
464  register short **new_R;
465  register short **temp_R;
466  register short *nedges;
467  register short *sp;
468  register int i;
469  register int k;
470 
471  nedges = NEW2(n, short);
472 
473  for (i = 0; i < n; i++)
474  {
475  sp = R[i];
476  if (sp)
477  {
478  while (*sp >= 0)
479  nedges[*sp++]++;
480  }
481  }
482 
483  new_R = NEW2(n, short *);
484  temp_R = NEW2(n, short *);
485 
486  for (i = 0; i < n; i++)
487  {
488  k = nedges[i];
489  if (k > 0)
490  {
491  sp = NEW2(k + 1, short);
492  new_R[i] = sp;
493  temp_R[i] = sp;
494  sp[k] = -1;
495  }
496  }
497 
498  FREE(nedges);
499 
500  for (i = 0; i < n; i++)
501  {
502  sp = R[i];
503  if (sp)
504  {
505  while (*sp >= 0)
506  *temp_R[*sp++]++ = i;
507  }
508  }
509 
510  FREE(temp_R);
511 
512  return (new_R);
513 }
#define NEW2(n, t)
Definition: defs.h:105
#define FREE(x)
Definition: defs.h:102
static short ** R
Definition: lalr.c:31
traverse ( int  i)

Definition at line 584 of file lalr.c.

References base, F, INDEX, infinity, R, tokensetsize, top, and VERTICES.

Referenced by digraph().

586 {
587  register unsigned *fp1;
588  register unsigned *fp2;
589  register unsigned *fp3;
590  register int j;
591  register short *rp;
592 
593  int height;
594  unsigned *base;
595 
596  VERTICES[++top] = i;
597  INDEX[i] = height = top;
598 
599  base = F + i * tokensetsize;
600  fp3 = base + tokensetsize;
601 
602  rp = R[i];
603  if (rp)
604  {
605  while ((j = *rp++) >= 0)
606  {
607  if (INDEX[j] == 0)
608  traverse(j);
609 
610  if (INDEX[i] > INDEX[j])
611  INDEX[i] = INDEX[j];
612 
613  fp1 = base;
614  fp2 = F + j * tokensetsize;
615 
616  while (fp1 < fp3)
617  *fp1++ |= *fp2++;
618  }
619  }
620 
621  if (INDEX[i] == height)
622  {
623  for (;;)
624  {
625  j = VERTICES[top--];
626  INDEX[j] = infinity;
627 
628  if (i == j)
629  break;
630 
631  fp1 = base;
632  fp2 = F + j * tokensetsize;
633 
634  while (fp1 < fp3)
635  *fp2++ = *fp1++;
636  }
637  }
638 }
static short * VERTICES
Definition: lalr.c:33
static short * INDEX
Definition: lalr.c:32
static int infinity
Definition: lalr.c:25
static int top
Definition: lalr.c:34
static unsigned * F
Definition: lalr.c:28
int tokensetsize
Definition: lalr.c:11
static short ** R
Definition: lalr.c:31
traverse(int i)
Definition: lalr.c:584
static short * base
Definition: output.c:11

+ Here is the caller graph for this function:

Variable Documentation

unsigned* F
static

Definition at line 28 of file lalr.c.

Referenced by compute_lookaheads(), initialize_F(), and traverse().

short* from_state

Definition at line 20 of file lalr.c.

Referenced by build_relations(), map_goto(), output_actions(), save_column(), and set_goto_map().

short* goto_map

Definition at line 19 of file lalr.c.

Referenced by default_goto(), map_goto(), output_actions(), save_column(), and set_goto_map().

short** includes
static

Definition at line 29 of file lalr.c.

Referenced by build_relations(), and compute_FOLLOWS().

short* INDEX
static

Definition at line 32 of file lalr.c.

Referenced by digraph(), and traverse().

int infinity
static

Definition at line 25 of file lalr.c.

Referenced by digraph(), and traverse().

unsigned* LA

Definition at line 14 of file lalr.c.

Referenced by add_reductions(), compute_lookaheads(), initialize_LA(), and output_actions().

short* LAruleno

Definition at line 13 of file lalr.c.

Referenced by add_lookback_edge(), add_reductions(), initialize_LA(), and output_actions().

short* lookaheads
shorts** lookback
static

Definition at line 30 of file lalr.c.

int maxrhs
static

Definition at line 26 of file lalr.c.

Referenced by build_relations(), and set_maxrhs().

int ngotos
static

Definition at line 27 of file lalr.c.

Referenced by build_relations(), digraph(), initialize_F(), and set_goto_map().

short** R
static

Definition at line 31 of file lalr.c.

Referenced by digraph(), reflexive_transitive_closure(), transitive_closure(), and traverse().

reductions** reduction_table

Definition at line 18 of file lalr.c.

Referenced by free_reductions().

shifts** shift_table

Definition at line 17 of file lalr.c.

Referenced by find_final_state(), free_shifts(), get_shifts(), print_actions(), and print_gotos().

core** state_table

Definition at line 16 of file lalr.c.

Referenced by free_itemsets(), and print_core().

int tokensetsize

Definition at line 11 of file lalr.c.

Referenced by add_reductions(), compute_lookaheads(), initialize_F(), initialize_LA(), lalr(), and traverse().

int top
static

Definition at line 34 of file lalr.c.

Referenced by digraph(), and traverse().

short* VERTICES
static

Definition at line 33 of file lalr.c.

Referenced by digraph(), and traverse().