summaryrefslogtreecommitdiff
path: root/devel/gaa/files/patch-bison
blob: bf822d359dfd499b8471e8bda3b082771e1c9676 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--- source/gaa_parser.y.orig	2004-04-15 10:52:42 UTC
+++ source/gaa_parser.y
@@ -22,7 +22,6 @@
 
 /* needed in newer bisons for yytoknum.
  */
-#define YYPRINT
 #define YYERROR_VERBOSE
 
 #include <stdio.h>
@@ -373,8 +372,6 @@ void copy_str(FILE* fd, int offset, FILE* out, const c
 %token AS "as"
 %token OPTIONAL "optional"
 
-%token_table
-
 %%
 
 input:
@@ -636,6 +633,32 @@ line:
 
 %%
 
+struct token_table_struct {
+    const char *str;
+    int token;
+};
+
+static struct token_table_struct token_table[] = {
+    {"IDENTIFIER", IDENTIFIER},
+    {"ACTION", ACTION},
+    {"TERMINATE", TERMINATE},
+    {"CSOURCE", CSOURCE},
+    {"CPART", CPART},
+    {"TYPE", TYPE},
+    {"STRING", STRING},
+    {"UNDERSCORE_STRINGS", UNDERSCORE_STRINGS},
+    {"init", INIT},
+    {"defitem", DEFITEM},
+    {"option", OPTION},
+    {"rest", REST},
+    {"helpnode", HELPNODE},
+    {"obligat", OBLIGATORY},
+    {"incomp", INCOMPATIBLE},
+    {"data", DATA},
+    {"as", AS},
+    {"optional", OPTIONAL},
+};
+
 extern int loc_index;
 
 struct _idStruct;
@@ -720,17 +743,9 @@ int length(char *a)
 
 int getTokenNum( char* str) {
 int i;
-     for (i = 0; i < YYNTOKENS; i++)
-     {
-     	   if (yytname[i] != 0
-		&& yytname[i][0] == '"'
-    	        && strncasecmp (yytname[i] + 1, str, strlen (str)) == 0
- 	        && yytname[i][strlen (str) + 1] == '"'
-                && yytname[i][strlen (str) + 2] == 0)
-	   {
-	       return yytoknum[i];
-	   }
-     }
+     for (i = 0; i < (sizeof(token_table)/sizeof(token_table[0])); i++)
+        if (!strcmp (token_table[i].str, str))
+            return token_table[i].token;
      return -1;
 }