]> git.saurik.com Git - bison.git/blame - src/muscle_tab.c
Regen.
[bison.git] / src / muscle_tab.c
CommitLineData
f753cd62 1/* Macro table manager for Bison,
a870c567 2 Copyright 2001 Free Software Foundation, Inc.
f753cd62
MA
3
4 This file is part of Bison, the GNU Compiler Compiler.
5
6 Bison is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 Bison is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Bison; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
f753cd62
MA
21#include "system.h"
22#include "hash.h"
23#include "files.h"
24#include "muscle_tab.h"
f508cb0a 25#include "getargs.h"
f753cd62
MA
26
27struct hash_table muscle_table;
28
29static unsigned long
30mhash1 (const void *item)
31{
a870c567 32 return_STRING_HASH_1 (((const muscle_entry_t *) item)->key);
f753cd62
MA
33}
34
35static unsigned long
36mhash2 (const void *item)
37{
a870c567 38 return_STRING_HASH_2 (((const muscle_entry_t *) item)->key);
f753cd62
MA
39}
40
41static int
42mcmp (const void *x, const void *y)
43{
a870c567
AD
44 return strcmp (((const muscle_entry_t*) x)->key,
45 ((const muscle_entry_t *) y)->key);
f753cd62
MA
46}
47
48void
49muscle_init (void)
50{
51 hash_init (&muscle_table, MTABSIZE, &mhash1, &mhash2, &mcmp);
52
53 /* Version and input file. */
54 muscle_insert ("version", VERSION);
55 muscle_insert ("filename", infile);
56
57 /* Types. */
58 muscle_insert ("stype", "int");
59 muscle_insert ("ltype", "yyltype");
60
f753cd62 61 /* Tables. */
bdef2a41
AD
62 muscle_insert ("rhs", NULL);
63 muscle_insert ("pact", NULL);
64 muscle_insert ("prhs", NULL);
65 muscle_insert ("stos", NULL);
66 muscle_insert ("check", NULL);
67 muscle_insert ("pgoto", NULL);
68 muscle_insert ("table", NULL);
69 muscle_insert ("tname", NULL);
70 muscle_insert ("defact", NULL);
71 muscle_insert ("toknum", NULL);
72 muscle_insert ("defgoto", NULL);
73 muscle_insert ("translate", NULL);
f753cd62
MA
74
75 /* Various macros. */
bdef2a41
AD
76 muscle_insert ("flag", NULL);
77 muscle_insert ("last", NULL);
78 muscle_insert ("pure", NULL);
79 muscle_insert ("nsym", NULL);
80 muscle_insert ("debug", NULL);
81 muscle_insert ("final", NULL);
82 muscle_insert ("maxtok", NULL);
83 muscle_insert ("ntbase", NULL);
84 muscle_insert ("error-verbose", NULL);
78af9bbc 85 muscle_insert ("prefix", NULL);
25b222fa
MA
86 /* Default #line formatting. */
87 muscle_insert ("linef", "#line %d %s\n");
f753cd62
MA
88
89 /* No parser macros. */
bdef2a41
AD
90 muscle_insert ("nnts", NULL);
91 muscle_insert ("nrules", NULL);
92 muscle_insert ("nstates", NULL);
93 muscle_insert ("ntokens", NULL);
f753cd62
MA
94
95 /* Stack parameters. */
96 muscle_insert ("maxdepth", "10000");
97 muscle_insert ("initdepth", "200");
98
99 /* C++ macros. */
100 muscle_insert ("name", "Parser");
101}
102
a870c567 103void
f753cd62
MA
104muscle_insert (const char *key, const char *value)
105{
106 muscle_entry_t *pair = XMALLOC (muscle_entry_t, 1);
107 pair->key = key;
108 pair->value = value;
109 hash_insert (&muscle_table, pair);
110}
111
112const char*
113muscle_find (const char *key)
114{
115 muscle_entry_t pair = { key, 0 };
116 muscle_entry_t *result = hash_find_item (&muscle_table, &pair);
117 return result ? result->value : 0;
118}