aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/zconf.l
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2005-11-09 00:34:51 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:55:53 -0500
commit7a88488bbc231e48a4a88ee2569bc0cc5d706f0a (patch)
tree2fd6b51b5cf76dd37a2a369a29c50b5121c12a92 /scripts/kconfig/zconf.l
parent491d711035dc08071ed58cf470f15efadb67cb1c (diff)
[PATCH] kconfig: use gperf for kconfig keywords
Use gperf to generate a hash for the kconfig keywords. This greatly reduces the size of the generated scanner and makes it easier to extend kconfig. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Cc: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts/kconfig/zconf.l')
-rw-r--r--scripts/kconfig/zconf.l53
1 files changed, 14 insertions, 39 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 55517b2877cd..ec902091be97 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -18,8 +18,7 @@
18 18
19#define START_STRSIZE 16 19#define START_STRSIZE 16
20 20
21char *text; 21static char *text;
22static char *text_ptr;
23static int text_size, text_asize; 22static int text_size, text_asize;
24 23
25struct buffer { 24struct buffer {
@@ -38,23 +37,22 @@ void new_string(void)
38{ 37{
39 text = malloc(START_STRSIZE); 38 text = malloc(START_STRSIZE);
40 text_asize = START_STRSIZE; 39 text_asize = START_STRSIZE;
41 text_ptr = text;
42 text_size = 0; 40 text_size = 0;
43 *text_ptr = 0; 41 *text = 0;
44} 42}
45 43
46void append_string(const char *str, int size) 44void append_string(const char *str, int size)
47{ 45{
48 int new_size = text_size + size + 1; 46 int new_size = text_size + size + 1;
49 if (new_size > text_asize) { 47 if (new_size > text_asize) {
48 new_size += START_STRSIZE - 1;
49 new_size &= -START_STRSIZE;
50 text = realloc(text, new_size); 50 text = realloc(text, new_size);
51 text_asize = new_size; 51 text_asize = new_size;
52 text_ptr = text + text_size;
53 } 52 }
54 memcpy(text_ptr, str, size); 53 memcpy(text + text_size, str, size);
55 text_ptr += size;
56 text_size += size; 54 text_size += size;
57 *text_ptr = 0; 55 text[text_size] = 0;
58} 56}
59 57
60void alloc_string(const char *str, int size) 58void alloc_string(const char *str, int size)
@@ -88,36 +86,12 @@ n [A-Za-z0-9_]
88 86
89 87
90<COMMAND>{ 88<COMMAND>{
91 "mainmenu" BEGIN(PARAM); return T_MAINMENU;
92 "menu" BEGIN(PARAM); return T_MENU;
93 "endmenu" BEGIN(PARAM); return T_ENDMENU;
94 "source" BEGIN(PARAM); return T_SOURCE;
95 "choice" BEGIN(PARAM); return T_CHOICE;
96 "endchoice" BEGIN(PARAM); return T_ENDCHOICE;
97 "comment" BEGIN(PARAM); return T_COMMENT;
98 "config" BEGIN(PARAM); return T_CONFIG;
99 "menuconfig" BEGIN(PARAM); return T_MENUCONFIG;
100 "help" BEGIN(PARAM); return T_HELP;
101 "if" BEGIN(PARAM); return T_IF;
102 "endif" BEGIN(PARAM); return T_ENDIF;
103 "depends" BEGIN(PARAM); return T_DEPENDS;
104 "requires" BEGIN(PARAM); return T_REQUIRES;
105 "optional" BEGIN(PARAM); return T_OPTIONAL;
106 "default" BEGIN(PARAM); return T_DEFAULT;
107 "prompt" BEGIN(PARAM); return T_PROMPT;
108 "tristate" BEGIN(PARAM); return T_TRISTATE;
109 "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE;
110 "bool" BEGIN(PARAM); return T_BOOLEAN;
111 "boolean" BEGIN(PARAM); return T_BOOLEAN;
112 "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN;
113 "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN;
114 "int" BEGIN(PARAM); return T_INT;
115 "hex" BEGIN(PARAM); return T_HEX;
116 "string" BEGIN(PARAM); return T_STRING;
117 "select" BEGIN(PARAM); return T_SELECT;
118 "enable" BEGIN(PARAM); return T_SELECT;
119 "range" BEGIN(PARAM); return T_RANGE;
120 {n}+ { 89 {n}+ {
90 struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
91 if (id && id->flags & TF_COMMAND) {
92 BEGIN(PARAM);
93 return id->token;
94 }
121 alloc_string(yytext, yyleng); 95 alloc_string(yytext, yyleng);
122 zconflval.string = text; 96 zconflval.string = text;
123 return T_WORD; 97 return T_WORD;
@@ -134,8 +108,6 @@ n [A-Za-z0-9_]
134 "!" return T_NOT; 108 "!" return T_NOT;
135 "=" return T_EQUAL; 109 "=" return T_EQUAL;
136 "!=" return T_UNEQUAL; 110 "!=" return T_UNEQUAL;
137 "if" return T_IF;
138 "on" return T_ON;
139 \"|\' { 111 \"|\' {
140 str = yytext[0]; 112 str = yytext[0];
141 new_string(); 113 new_string();
@@ -144,6 +116,9 @@ n [A-Za-z0-9_]
144 \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; 116 \n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
145 --- /* ignore */ 117 --- /* ignore */
146 ({n}|[-/.])+ { 118 ({n}|[-/.])+ {
119 struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
120 if (id && id->flags & TF_PARAM)
121 return id->token;
147 alloc_string(yytext, yyleng); 122 alloc_string(yytext, yyleng);
148 zconflval.string = text; 123 zconflval.string = text;
149 return T_WORD; 124 return T_WORD;