Skip to content

Commit f6a88aa

Browse files
Roman ZippelSam Ravnborg
authored andcommitted
kconfig: add symbol option config syntax
This adds the general framework to the parser to define options for config symbols with a syntax like: config FOO option bar[="arg"] Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1 parent f1d28fb commit f6a88aa

7 files changed

Lines changed: 735 additions & 492 deletions

File tree

‎scripts/kconfig/lex.zconf.c_shipped‎

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define FLEX_SCANNER
99
#define YY_FLEX_MAJOR_VERSION 2
1010
#define YY_FLEX_MINOR_VERSION 5
11-
#define YY_FLEX_SUBMINOR_VERSION 31
11+
#define YY_FLEX_SUBMINOR_VERSION 33
1212
#if YY_FLEX_SUBMINOR_VERSION > 0
1313
#define FLEX_BETA
1414
#endif
@@ -30,7 +30,15 @@
3030

3131
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
3232

33-
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
33+
#if __STDC_VERSION__ >= 199901L
34+
35+
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36+
* if you want the limit (max/min) macros for int types.
37+
*/
38+
#ifndef __STDC_LIMIT_MACROS
39+
#define __STDC_LIMIT_MACROS 1
40+
#endif
41+
3442
#include <inttypes.h>
3543
typedef int8_t flex_int8_t;
3644
typedef uint8_t flex_uint8_t;
@@ -134,6 +142,10 @@ typedef unsigned int flex_uint32_t;
134142
#define YY_BUF_SIZE 16384
135143
#endif
136144

145+
/* The state buf must be large enough to hold one state per character in the main buffer.
146+
*/
147+
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
148+
137149
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
138150
#define YY_TYPEDEF_YY_BUFFER_STATE
139151
typedef struct yy_buffer_state *YY_BUFFER_STATE;
@@ -267,7 +279,7 @@ int zconfleng;
267279

268280
/* Points to current character in buffer. */
269281
static char *yy_c_buf_p = (char *) 0;
270-
static int yy_init = 1; /* whether we need to initialize */
282+
static int yy_init = 0; /* whether we need to initialize */
271283
static int yy_start = 0; /* start state number */
272284

273285
/* Flag which is used to allow zconfwrap()'s to do buffer switches
@@ -820,6 +832,8 @@ void alloc_string(const char *str, int size)
820832
#define YY_EXTRA_TYPE void *
821833
#endif
822834

835+
static int yy_init_globals (void );
836+
823837
/* Macros after this point can all be overridden by user definitions in
824838
* section 1.
825839
*/
@@ -942,9 +956,9 @@ YY_DECL
942956
int str = 0;
943957
int ts, i;
944958

945-
if ( (yy_init) )
959+
if ( !(yy_init) )
946960
{
947-
(yy_init) = 0;
961+
(yy_init) = 1;
948962

949963
#ifdef YY_USER_INIT
950964
YY_USER_INIT;
@@ -1452,7 +1466,7 @@ static int yy_get_next_buffer (void)
14521466

14531467
else
14541468
{
1455-
size_t num_to_read =
1469+
int num_to_read =
14561470
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
14571471

14581472
while ( num_to_read <= 0 )
@@ -1969,16 +1983,16 @@ YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
19691983

19701984
/** Setup the input buffer state to scan a string. The next call to zconflex() will
19711985
* scan from a @e copy of @a str.
1972-
* @param yy_str a NUL-terminated string to scan
1986+
* @param yystr a NUL-terminated string to scan
19731987
*
19741988
* @return the newly allocated buffer state object.
19751989
* @note If you want to scan bytes that may contain NUL values, then use
19761990
* zconf_scan_bytes() instead.
19771991
*/
1978-
YY_BUFFER_STATE zconf_scan_string (yyconst char * yy_str )
1992+
YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr )
19791993
{
19801994

1981-
return zconf_scan_bytes(yy_str,strlen(yy_str) );
1995+
return zconf_scan_bytes(yystr,strlen(yystr) );
19821996
}
19831997

19841998
/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
@@ -1988,23 +2002,23 @@ YY_BUFFER_STATE zconf_scan_string (yyconst char * yy_str )
19882002
*
19892003
* @return the newly allocated buffer state object.
19902004
*/
1991-
YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len )
2005+
YY_BUFFER_STATE zconf_scan_bytes (yyconst char * yybytes, int _yybytes_len )
19922006
{
19932007
YY_BUFFER_STATE b;
19942008
char *buf;
19952009
yy_size_t n;
19962010
int i;
19972011

19982012
/* Get memory for full buffer, including space for trailing EOB's. */
1999-
n = len + 2;
2013+
n = _yybytes_len + 2;
20002014
buf = (char *) zconfalloc(n );
20012015
if ( ! buf )
20022016
YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" );
20032017

2004-
for ( i = 0; i < len; ++i )
2005-
buf[i] = bytes[i];
2018+
for ( i = 0; i < _yybytes_len; ++i )
2019+
buf[i] = yybytes[i];
20062020

2007-
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
2021+
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
20082022

20092023
b = zconf_scan_buffer(buf,n );
20102024
if ( ! b )
@@ -2125,6 +2139,34 @@ void zconfset_debug (int bdebug )
21252139
zconf_flex_debug = bdebug ;
21262140
}
21272141

2142+
static int yy_init_globals (void)
2143+
{
2144+
/* Initialization is the same as for the non-reentrant scanner.
2145+
* This function is called from zconflex_destroy(), so don't allocate here.
2146+
*/
2147+
2148+
(yy_buffer_stack) = 0;
2149+
(yy_buffer_stack_top) = 0;
2150+
(yy_buffer_stack_max) = 0;
2151+
(yy_c_buf_p) = (char *) 0;
2152+
(yy_init) = 0;
2153+
(yy_start) = 0;
2154+
2155+
/* Defined in main.c */
2156+
#ifdef YY_STDINIT
2157+
zconfin = stdin;
2158+
zconfout = stdout;
2159+
#else
2160+
zconfin = (FILE *) 0;
2161+
zconfout = (FILE *) 0;
2162+
#endif
2163+
2164+
/* For future reference: Set errno on error, since we are called by
2165+
* zconflex_init()
2166+
*/
2167+
return 0;
2168+
}
2169+
21282170
/* zconflex_destroy is for both reentrant and non-reentrant scanners. */
21292171
int zconflex_destroy (void)
21302172
{
@@ -2140,6 +2182,10 @@ int zconflex_destroy (void)
21402182
zconffree((yy_buffer_stack) );
21412183
(yy_buffer_stack) = NULL;
21422184

2185+
/* Reset the globals. This is important in a non-reentrant scanner so the next time
2186+
* zconflex() is called, initialization will occur. */
2187+
yy_init_globals( );
2188+
21432189
return 0;
21442190
}
21452191

@@ -2151,7 +2197,7 @@ int zconflex_destroy (void)
21512197
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
21522198
{
21532199
register int i;
2154-
for ( i = 0; i < n; ++i )
2200+
for ( i = 0; i < n; ++i )
21552201
s1[i] = s2[i];
21562202
}
21572203
#endif
@@ -2160,7 +2206,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
21602206
static int yy_flex_strlen (yyconst char * s )
21612207
{
21622208
register int n;
2163-
for ( n = 0; s[n]; ++n )
2209+
for ( n = 0; s[n]; ++n )
21642210
;
21652211

21662212
return n;
@@ -2191,19 +2237,6 @@ void zconffree (void * ptr )
21912237

21922238
#define YYTABLES_NAME "yytables"
21932239

2194-
#undef YY_NEW_FILE
2195-
#undef YY_FLUSH_BUFFER
2196-
#undef yy_set_bol
2197-
#undef yy_new_buffer
2198-
#undef yy_set_interactive
2199-
#undef yytext_ptr
2200-
#undef YY_DO_BEFORE_ACTION
2201-
2202-
#ifdef YY_DECL_IS_OURS
2203-
#undef YY_DECL_IS_OURS
2204-
#undef YY_DECL
2205-
#endif
2206-
22072240
void zconf_starthelp(void)
22082241
{
22092242
new_string();

‎scripts/kconfig/lkc.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ extern "C" {
4040

4141
#define TF_COMMAND 0x0001
4242
#define TF_PARAM 0x0002
43+
#define TF_OPTION 0x0004
44+
45+
#define T_OPT_MODULES 1
46+
#define T_OPT_DEFCONFIG_LIST 2
4347

4448
struct kconf_id {
4549
int name;
@@ -78,6 +82,7 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
7882
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
7983
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
8084
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
85+
void menu_add_option(int token, char *arg);
8186
void menu_finalize(struct menu *parent);
8287
void menu_set_type(int type);
8388

‎scripts/kconfig/menu.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
152152
menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
153153
}
154154

155+
void menu_add_option(int token, char *arg)
156+
{
157+
}
158+
155159
static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
156160
{
157161
return sym2->type == S_INT || sym2->type == S_HEX ||

‎scripts/kconfig/zconf.gperf‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ string, T_TYPE, TF_COMMAND, S_STRING
3939
select, T_SELECT, TF_COMMAND
4040
enable, T_SELECT, TF_COMMAND
4141
range, T_RANGE, TF_COMMAND
42+
option, T_OPTION, TF_COMMAND
4243
on, T_ON, TF_PARAM
44+
modules, T_OPT_MODULES, TF_OPTION
45+
defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION
4346
%%

0 commit comments

Comments
 (0)