summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@epita.fr>2000-10-02 08:35:47 +0000
committerAkim Demaille <akim@epita.fr>2000-10-02 08:35:47 +0000
commit340ef489223a5d1f9c40674ea2973435cb8ecc1b (patch)
tree8226bb0788f703e33987944d493f5c120a869368
parentb2ca4022ea6c61e10ac87a0a92bb0f998ecf8b48 (diff)
downloadbison-340ef489223a5d1f9c40674ea2973435cb8ecc1b.tar.gz
Various anti-`extern in *.c' changes.
* src/system.h: Include `assert.h'.
-rw-r--r--ChangeLog7
-rw-r--r--src/LR0.c2
-rw-r--r--src/closure.c6
-rw-r--r--src/closure.h7
-rw-r--r--src/conflicts.h1
-rw-r--r--src/derives.c4
-rw-r--r--src/derives.h6
-rw-r--r--src/lalr.c36
-rw-r--r--src/lex.c3
-rw-r--r--src/lex.h9
-rw-r--r--src/output.c3
-rw-r--r--src/reader.c9
-rw-r--r--src/symtab.c4
-rw-r--r--src/symtab.h87
-rw-r--r--src/system.h2
15 files changed, 97 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog
index 9edf8184..b7a14eb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2000-10-02 Akim Demaille <akim@epita.fr>
+ Various anti-`extern in *.c' changes.
+
+ * src/system.h: Include `assert.h'.
+
+
+2000-10-02 Akim Demaille <akim@epita.fr>
+
* src/state.h (nstates, final_state, first_state, first_shift)
(first_reduction): Move their exportation from here...
* src/LR0.h: to here.
diff --git a/src/LR0.c b/src/LR0.c
index 9643ee8d..57f6459d 100644
--- a/src/LR0.c
+++ b/src/LR0.c
@@ -30,8 +30,6 @@
#include "closure.h"
#include "LR0.h"
-extern short *itemset;
-extern short *itemsetend;
int nstates;
int final_state;
diff --git a/src/closure.c b/src/closure.c
index 87ad8c5f..68b64690 100644
--- a/src/closure.c
+++ b/src/closure.c
@@ -18,15 +18,11 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
-
#include "system.h"
#include "alloc.h"
#include "gram.h"
#include "closure.h"
-
-extern short **derives;
-
-extern void RTC PARAMS ((unsigned *, int));
+#include "derives.h"
short *itemset;
short *itemsetend;
diff --git a/src/closure.h b/src/closure.h
index 2325e7c4..08921c81 100644
--- a/src/closure.h
+++ b/src/closure.h
@@ -18,6 +18,8 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
+#ifndef CLOSURE_H_
+# define CLOSURE_H_
/* Subroutines of file LR0.c. */
@@ -47,3 +49,8 @@ void closure PARAMS ((short *items, int n));
/* Frees itemset, ruleset and internal data. */
void free_closure PARAMS ((void));
+
+extern short *itemset;
+extern short *itemsetend;
+
+#endif /* !CLOSURE_H_ */
diff --git a/src/conflicts.h b/src/conflicts.h
index 43c8a2c6..88c78aa2 100644
--- a/src/conflicts.h
+++ b/src/conflicts.h
@@ -20,6 +20,7 @@
#ifndef CONFLICTS_H_
# define CONFLICTS_H_
+# include "state.h"
void initialize_conflicts PARAMS ((void));
void print_conflicts PARAMS ((void));
diff --git a/src/derives.c b/src/derives.c
index 3c1d3f62..9bd37c92 100644
--- a/src/derives.c
+++ b/src/derives.c
@@ -30,6 +30,8 @@
#include "gram.h"
#include "derives.h"
+short **derives;
+
#if DEBUG
static void
@@ -55,8 +57,6 @@ print_derives (void)
#endif
-short **derives;
-
void
set_derives (void)
{
diff --git a/src/derives.h b/src/derives.h
index d9505aba..58817471 100644
--- a/src/derives.h
+++ b/src/derives.h
@@ -18,6 +18,10 @@
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#ifndef DERIVES_H_
+# define DERIVES_H_
+
+extern short **derives;
/* set_derives finds, for each variable (nonterminal), which rules can
derive it. It sets up the value of derives so that derives[i -
@@ -26,3 +30,5 @@
void set_derives PARAMS((void));
void free_derives PARAMS((void));
+
+#endif /* !DERIVES_H_ */
diff --git a/src/lalr.c b/src/lalr.c
index 742ff604..af2ea100 100644
--- a/src/lalr.c
+++ b/src/lalr.c
@@ -1,27 +1,27 @@
/* Compute look-ahead criteria for bison,
- Copyright (C) 1984, 1986, 1989 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 2000 Free Software Foundation, Inc.
-This file is part of Bison, the GNU Compiler Compiler.
+ This file is part of Bison, the GNU Compiler Compiler.
-Bison is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+ Bison is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
-Bison is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ Bison is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with Bison; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with Bison; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
/* Compute how to make the finite state machine deterministic; find
which rules need lookahead in each state, and which lookahead
- tokens they accept. */
+ tokens they accept. */
#include "system.h"
#include "types.h"
@@ -31,8 +31,7 @@ Boston, MA 02111-1307, USA. */
#include "complain.h"
#include "lalr.h"
#include "nullable.h"
-
-extern short **derives;
+#include "derives.h"
int tokensetsize;
short *lookaheads;
@@ -481,8 +480,7 @@ add_lookback_edge (int stateno, int ruleno, int gotono)
i++;
}
- if (found == 0)
- berror ("add_lookback_edge");
+ assert (found);
sp = NEW (shorts);
sp->next = lookback[i];
diff --git a/src/lex.c b/src/lex.c
index 27df7f1a..e2a94ad7 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -28,9 +28,6 @@
#include "complain.h"
#include "gram.h"
-/*spec_outfile is declared in files.h, for -o */
-
-
/* functions from main.c */
extern char *printable_version PARAMS ((int));
diff --git a/src/lex.h b/src/lex.h
index c817cee2..3831e5af 100644
--- a/src/lex.h
+++ b/src/lex.h
@@ -53,8 +53,13 @@
# define MAXTOKEN 1024
-void init_lex PARAMS ((void));
+
+/* Allocated size of token_buffer, not including space for terminator. */
+extern int maxtoken;
+extern char *token_buffer;
char *grow_token_buffer PARAMS ((char *));
+
+void init_lex PARAMS ((void));
int skip_white_space PARAMS ((void));
void unlex PARAMS ((int));
@@ -67,5 +72,7 @@ int lex PARAMS ((void));
int parse_percent_token PARAMS ((void));
+extern bucket *symval;
+extern int numval;
#endif /* !LEX_H_ */
diff --git a/src/output.c b/src/output.c
index 214300db..0da18d00 100644
--- a/src/output.c
+++ b/src/output.c
@@ -993,8 +993,7 @@ pack_vector (int vector)
i = order[vector];
t = tally[i];
- if (t == 0)
- berror ("pack_vector");
+ assert (t);
from = froms[i];
to = tos[i];
diff --git a/src/reader.c b/src/reader.c
index c89313e2..ded07a70 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -30,15 +30,8 @@
#include "complain.h"
#include "output.h"
#include "reader.h"
+#include "conflicts.h"
-extern bucket *symval;
-extern int numval;
-extern int expected_conflicts;
-extern char *token_buffer;
-extern int maxtoken;
-
-extern void tabinit PARAMS ((void));
-extern void free_symtab PARAMS ((void));
extern char *printable_version PARAMS ((int));
#define LTYPESTR "\
diff --git a/src/symtab.c b/src/symtab.c
index f258386e..451c518f 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -29,10 +29,6 @@ bucket *firstsymbol;
static bucket *lastsymbol;
static bucket **symtab;
-extern void tabinit PARAMS((void));
-extern void free_symtab PARAMS((void));
-
-
static int
hash (const char *key)
{
diff --git a/src/symtab.h b/src/symtab.h
index e3000919..03ae90f4 100644
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -1,59 +1,60 @@
/* Definitions for symtab.c and callers, part of bison,
- Copyright (C) 1984, 1989, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1992, 2000 Free Software Foundation, Inc.
-This file is part of Bison, the GNU Compiler Compiler.
+ This file is part of Bison, the GNU Compiler Compiler.
-Bison is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+ Bison is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
-Bison is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ Bison is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with Bison; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with Bison; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#ifndef SYMTAB_H_
+# define SYMTAB_H_
#define TABSIZE 1009
-
/* symbol classes */
#define SUNKNOWN 0
-#define STOKEN 1 /* terminal symbol */
-#define SNTERM 2 /* non-terminal */
-
-#define SALIAS -9991 /* for symbol generated with an alias */
-
-typedef
- struct bucket
- {
- struct bucket *link;
- struct bucket *next;
- char *tag;
- char *type_name;
- short value;
- short prec;
- short assoc;
- short user_token_number;
- /* special value SALIAS in the identifier
- half of the identifier-symbol pair for an alias */
- struct bucket *alias;
- /* points to the other in the identifier-symbol
- pair for an alias */
- char class;
- }
- bucket;
+#define STOKEN 1 /* terminal symbol */
+#define SNTERM 2 /* non-terminal */
+
+#define SALIAS -9991 /* for symbol generated with an alias */
+
+typedef struct bucket
+{
+ struct bucket *link;
+ struct bucket *next;
+ char *tag;
+ char *type_name;
+ short value;
+ short prec;
+ short assoc;
+ short user_token_number;
+ /* special value SALIAS in the identifier half of the
+ identifier-symbol pair for an alias */
+ struct bucket *alias;
+ /* points to the other in the identifier-symbol pair for an alias */
+ char class;
+}
+bucket;
extern bucket *firstsymbol;
-extern bucket *getsym PARAMS((const char *));
+bucket *getsym PARAMS ((const char *));
+
+void tabinit PARAMS ((void));
+void free_symtab PARAMS ((void));
+
+#endif /* !SYMTAB_H_ */
diff --git a/src/system.h b/src/system.h
index ae02b619..82d31c57 100644
--- a/src/system.h
+++ b/src/system.h
@@ -24,6 +24,8 @@
#include <stdio.h>
+#include <assert.h>
+
#ifdef MSDOS
# include <io.h>
#endif