Use lib/hash for the symbol table.

* src/gram.c (ntokens): Initialize to 1, to reserve a slot for
EOF.
* src/lex.c (lex): Set the `number' member of new terminals.
* src/reader.c (bucket_check_defined, bucket_make_alias)
(bucket_check_alias_consistence, bucket_translation): New.
(reader, grammar_free, readgram, token_translations_init)
(packsymbols): Adjust.
(reader): Number the predefined tokens.
* src/reduce.c (inaccessable_symbols): Just use hard coded numbers
for predefined tokens.
* src/symtab.h (bucket): Remove all the hash table related
members.
* src/symtab.c (symtab): Replace by...
(bucket_table): this.
(bucket_new, bucket_free, hash_compare_bucket, hash_bucket)
(buckets_new, buckets_do): New.
This commit is contained in:
Akim Demaille
2002-04-07 17:43:21 +00:00
parent 280a38c306
commit 72a23c9797
7 changed files with 360 additions and 232 deletions

View File

@@ -46,10 +46,6 @@ typedef enum
typedef struct bucket
{
/* Needed for the hash table. */
struct bucket *link;
struct bucket *next;
/* The key, name of the symbol. */
char *tag;
/* Its type. */
@@ -66,12 +62,13 @@ typedef struct bucket
symbol_class class;
} bucket;
extern bucket *firstsymbol;
/* A function to apply to each symbol. */
typedef bool (*bucket_processor) PARAMS ((bucket *));
bucket *getsym PARAMS ((const char *));
void tabinit PARAMS ((void));
void free_symtab PARAMS ((void));
void buckets_new PARAMS ((void));
void buckets_do PARAMS ((bucket_processor processor, void *processor_data));
void buckets_free PARAMS ((void));
#endif /* !SYMTAB_H_ */