1 |
/* Part of the bison parser generator, |
/* Part of the bison parser generator, |
2 |
Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc. |
Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of Bison, the GNU Compiler Compiler. |
This file is part of Bison, the GNU Compiler Compiler. |
5 |
|
|
26 |
#include "system.h" |
#include "system.h" |
27 |
#include "getargs.h" |
#include "getargs.h" |
28 |
#include "symtab.h" |
#include "symtab.h" |
|
#include "types.h" |
|
29 |
#include "gram.h" |
#include "gram.h" |
30 |
#include "reduce.h" |
#include "reduce.h" |
31 |
#include "nullable.h" |
#include "nullable.h" |
32 |
|
|
33 |
|
/* Linked list of rule numbers. */ |
34 |
|
typedef struct rule_list_s |
35 |
|
{ |
36 |
|
struct rule_list_s *next; |
37 |
|
rule_number_t value; |
38 |
|
} rule_list_t; |
39 |
|
|
40 |
char *nullable = NULL; |
char *nullable = NULL; |
41 |
|
|
42 |
static void |
static void |
55 |
rule_number_t ruleno; |
rule_number_t ruleno; |
56 |
symbol_number_t *s1; |
symbol_number_t *s1; |
57 |
symbol_number_t *s2; |
symbol_number_t *s2; |
58 |
shorts *p; |
rule_list_t *p; |
59 |
|
|
60 |
symbol_number_t *squeue = XCALLOC (symbol_number_t, nvars); |
symbol_number_t *squeue = XCALLOC (symbol_number_t, nvars); |
61 |
short *rcount = XCALLOC (short, nrules + 1); |
short *rcount = XCALLOC (short, nrules + 1); |
62 |
/* RITEM contains all the rules, including useless productions. |
/* RITEM contains all the rules, including useless productions. |
63 |
Hence we must allocate room for useless nonterminals too. */ |
Hence we must allocate room for useless nonterminals too. */ |
64 |
shorts **rsets = XCALLOC (shorts *, nvars) - ntokens; |
rule_list_t **rsets = XCALLOC (rule_list_t *, nvars) - ntokens; |
65 |
/* This is said to be more elements than we actually use. |
/* This is said to be more elements than we actually use. |
66 |
Supposedly NRITEMS - NRULES is enough. But why take the risk? */ |
Supposedly NRITEMS - NRULES is enough. But why take the risk? */ |
67 |
shorts *relts = XCALLOC (shorts, nritems + nvars + 1); |
rule_list_t *relts = XCALLOC (rule_list_t, nritems + nvars + 1); |
68 |
|
|
69 |
if (trace_flag) |
if (trace_flag) |
70 |
fprintf (stderr, "Entering set_nullable\n"); |
fprintf (stderr, "Entering set_nullable\n"); |