/[bison]/bison/src/macrotab.c
ViewVC logotype

Diff of /bison/src/macrotab.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by pascal, Thu Aug 30 18:51:56 2001 UTC revision 1.5 by pascal, Fri Aug 31 16:56:44 2001 UTC
# Line 29  Line 29 
29  struct hash_table macro_table;  struct hash_table macro_table;
30    
31  static unsigned long  static unsigned long
32  mhash1 (const void* item)  mhash1 (const void *item)
33  {  {
34    return_STRING_HASH_1 (((macro_entry_t*) item)->key);    return_STRING_HASH_1 (((macro_entry_t *) item)->key);
35  }  }
36    
37  static unsigned long  static unsigned long
38  mhash2 (const void* item)  mhash2 (const void *item)
39  {  {
40    return_STRING_HASH_2 (((macro_entry_t*) item)->key);    return_STRING_HASH_2 (((macro_entry_t *) item)->key);
41  }  }
42    
43  static int  static int
44  mcmp (const void* x, const void* y)  mcmp (const void *x, const void *y)
45  {  {
46    return strcmp (((macro_entry_t*) x)->key, ((macro_entry_t*) y)->key);    return strcmp (((macro_entry_t*) x)->key, ((macro_entry_t *) y)->key);
47  }  }
48    
49  void  void
# Line 51  macro_init (void) Line 51  macro_init (void)
51  {  {
52    hash_init (&macro_table, MTABSIZE, &mhash1, &mhash2, &mcmp);    hash_init (&macro_table, MTABSIZE, &mhash1, &mhash2, &mcmp);
53    
54    /* Version and input file. */    /* Version and input file.  */
55    macro_insert ("version", VERSION);    macro_insert ("version", VERSION);
56    macro_insert ("filename", "a.y");    macro_insert ("filename", "a.y");
57    
58    /* Types. */    /* Types.  */
59    macro_insert ("stype", "int");    macro_insert ("stype", "int");
60    macro_insert ("ltype", "yyltype");    macro_insert ("ltype", "yyltype");
61    
62    /* Tokens. */    /* Tokens.  */
63    macro_insert ("tokendef", "");    macro_insert ("tokendef", "");
64    
65    /* Tables. */    /* Tables.  */
66    macro_insert ("rhs", "0");    macro_insert ("rhs", "0");
67    macro_insert ("pact", "0");    macro_insert ("pact", "0");
68    macro_insert ("prhs", "0");    macro_insert ("prhs", "0");
# Line 76  macro_init (void) Line 76  macro_init (void)
76    macro_insert ("defgoto", "0");    macro_insert ("defgoto", "0");
77    macro_insert ("translate", "0");    macro_insert ("translate", "0");
78    
79    /* Various macros. */    /* Various macros.  */
80    macro_insert ("flag", "0");    macro_insert ("flag", "0");
81    macro_insert ("last", "0");    macro_insert ("last", "0");
82    macro_insert ("pure", "0");    macro_insert ("pure", "0");
# Line 87  macro_init (void) Line 87  macro_init (void)
87    macro_insert ("ntbase", "0");    macro_insert ("ntbase", "0");
88    macro_insert ("verbose", "0");    macro_insert ("verbose", "0");
89    
90    /* Variable prefix names. */    /* Variable prefix names.  */
91    macro_insert ("yyparse", "yyparse");    macro_insert ("yyparse", "yyparse");
92    macro_insert ("yylex", "yylex");    macro_insert ("yylex", "yylex");
93    macro_insert ("yyerror", "yyerror");    macro_insert ("yyerror", "yyerror");
# Line 96  macro_init (void) Line 96  macro_init (void)
96    macro_insert ("yydebug", "yydebug");    macro_insert ("yydebug", "yydebug");
97    macro_insert ("yynerrs", "yynerrs");    macro_insert ("yynerrs", "yynerrs");
98    
99    /* No parser macros. */    /* No parser macros.  */
100    macro_insert ("nnts", "0");    macro_insert ("nnts", "0");
101    macro_insert ("nrules", "0");    macro_insert ("nrules", "0");
102    macro_insert ("nstates", "0");    macro_insert ("nstates", "0");
103    macro_insert ("ntokens", "0");    macro_insert ("ntokens", "0");
104    
105    /* Stack parameters. */    /* Stack parameters.  */
106    macro_insert ("maxdepth", "10000");    macro_insert ("maxdepth", "10000");
107    macro_insert ("initdepth", "200");    macro_insert ("initdepth", "200");
108    
109    /* C++ macros. */    /* C++ macros.  */
110    macro_insert ("name", "Parser");    macro_insert ("name", "Parser");
111  }  }
112    
113  void  void
114  macro_insert (const char *key, const char *value)  macro_insert (const char *key, const char *value)
115  {  {
116    macro_entry_t* pair = XMALLOC (macro_entry_t, 1);    macro_entry_t *pair = XMALLOC (macro_entry_t, 1);
117    pair->key = key;    pair->key = key;
118    pair->value = value;    pair->value = value;
119    hash_insert (&macro_table, pair);    hash_insert (&macro_table, pair);
# Line 123  const char* Line 123  const char*
123  macro_find (const char *key)  macro_find (const char *key)
124  {  {
125    macro_entry_t pair = { key, 0 };    macro_entry_t pair = { key, 0 };
126    macro_entry_t* result = hash_find_item (&macro_table, &pair);    macro_entry_t *result = hash_find_item (&macro_table, &pair);
127    return result ? result->value : 0;    return result ? result->value : 0;
128  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26