summaryrefslogtreecommitdiff
path: root/adk/config/zconf.y
diff options
context:
space:
mode:
Diffstat (limited to 'adk/config/zconf.y')
-rw-r--r--adk/config/zconf.y124
1 files changed, 83 insertions, 41 deletions
diff --git a/adk/config/zconf.y b/adk/config/zconf.y
index b4240c846..fdc6fdce2 100644
--- a/adk/config/zconf.y
+++ b/adk/config/zconf.y
@@ -11,11 +11,8 @@
#include <string.h>
#include <stdbool.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
-#include "zconf.hash.c"
-
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
#define PRINTD 0x0001
@@ -27,18 +24,14 @@ extern int zconflex(void);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
-struct symbol *symbol_hash[257];
+struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
-#define YYDEBUG 0
-#if YYDEBUG
-#define YYERROR_VERBOSE
-#endif
%}
-%expect 26
+%expect 30
%union
{
@@ -47,7 +40,7 @@ static struct menu *current_menu, *current_entry;
struct symbol *symbol;
struct expr *expr;
struct menu *menu;
- struct kconf_id *id;
+ const struct kconf_id *id;
}
%token <id>T_MAINMENU
@@ -70,6 +63,7 @@ static struct menu *current_menu, *current_entry;
%token <id>T_DEFAULT
%token <id>T_SELECT
%token <id>T_RANGE
+%token <id>T_VISIBLE
%token <id>T_OPTION
%token <id>T_ON
%token <string> T_WORD
@@ -100,15 +94,21 @@ static struct menu *current_menu, *current_entry;
menu_end_menu();
} if_entry menu_entry choice_entry
+%{
+/* Include zconf.hash.c here so it can see the token constants. */
+#include "zconf.hash.c"
+%}
+
%%
-input: stmt_list;
+input: nl start | start;
+
+start: mainmenu_stmt stmt_list | stmt_list;
stmt_list:
/* empty */
| stmt_list common_stmt
| stmt_list choice_stmt
| stmt_list menu_stmt
- | stmt_list T_MAINMENU prompt nl
| stmt_list end { zconf_error("unexpected end statement"); }
| stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
| stmt_list option_name error T_EOL
@@ -119,7 +119,7 @@ stmt_list:
;
option_name:
- T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT
+ T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
;
common_stmt:
@@ -207,10 +207,16 @@ config_option: T_DEFAULT expr if_expr T_EOL
config_option: T_SELECT T_WORD if_expr T_EOL
{
- menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3);
+ menu_add_select(sym_lookup($2, 0), NULL, $3);
printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
};
+config_option: T_SELECT T_WORD expr if_expr T_EOL
+{
+ menu_add_select(sym_lookup($2, 0), $3, $4);
+ printd(DEBUG_PARSE, "%s:%d:select with value\n", zconf_curname(), zconf_lineno());
+};
+
config_option: T_RANGE symbol symbol if_expr T_EOL
{
menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
@@ -224,7 +230,7 @@ symbol_option_list:
/* empty */
| symbol_option_list T_WORD symbol_option_arg
{
- struct kconf_id *id = kconf_id_lookup($2, strlen($2));
+ const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
if (id && id->flags & TF_OPTION)
menu_add_option(id->token, $3);
else
@@ -339,6 +345,13 @@ if_block:
| if_block choice_stmt
;
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU prompt nl
+{
+ menu_add_prompt(P_MENU, $2, NULL);
+};
+
/* menu entry */
menu: T_MENU prompt T_EOL
@@ -348,7 +361,7 @@ menu: T_MENU prompt T_EOL
printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
};
-menu_entry: menu depends_list
+menu_entry: menu visibility_list depends_list
{
$$ = menu_add_menu();
};
@@ -419,6 +432,19 @@ depends: T_DEPENDS T_ON expr T_EOL
printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
};
+/* visibility option */
+
+visibility_list:
+ /* empty */
+ | visibility_list visible
+ | visibility_list T_EOL
+;
+
+visible: T_VISIBLE if_expr
+{
+ menu_add_visibility($2);
+};
+
/* prompt statement */
prompt_stmt_opt:
@@ -472,36 +498,31 @@ void conf_parse(const char *name)
zconf_initscan(name);
sym_init();
- menu_init();
- modules_sym = sym_lookup(NULL, 0);
- modules_sym->type = S_BOOLEAN;
- modules_sym->flags |= SYMBOL_AUTO;
- rootmenu.prompt = menu_add_prompt(P_MENU, "OpenADK Configuration", NULL);
+ _menu_init();
+ rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
-#if YYDEBUG
if (getenv("ZCONF_DEBUG"))
zconfdebug = 1;
-#endif
zconfparse();
if (zconfnerrs)
exit(1);
- if (!modules_sym->prop) {
- struct property *prop;
+ if (!modules_sym)
+ modules_sym = sym_find( "n" );
+
+ rootmenu.prompt->text = _(rootmenu.prompt->text);
+ rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
- prop = prop_alloc(P_DEFAULT, modules_sym);
- prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
- }
menu_finalize(&rootmenu);
for_all_symbols(i, sym) {
if (sym_check_deps(sym))
zconfnerrs++;
- }
+ }
if (zconfnerrs)
exit(1);
sym_set_change_count(1);
}
-const char *zconf_tokenname(int token)
+static const char *zconf_tokenname(int token)
{
switch (token) {
case T_MENU: return "menu";
@@ -511,11 +532,12 @@ const char *zconf_tokenname(int token)
case T_IF: return "if";
case T_ENDIF: return "endif";
case T_DEPENDS: return "depends";
+ case T_VISIBLE: return "visible";
}
return "<token>";
}
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
{
if (id->token != endtoken) {
zconf_error("unexpected '%s' within %s block",
@@ -560,12 +582,10 @@ static void zconf_error(const char *err, ...)
static void zconferror(const char *err)
{
-#if YYDEBUG
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
-#endif
}
-void print_quoted_string(FILE *out, const char *str)
+static void print_quoted_string(FILE *out, const char *str)
{
const char *p;
int len;
@@ -582,15 +602,15 @@ void print_quoted_string(FILE *out, const char *str)
putc('"', out);
}
-void print_symbol(FILE *out, struct menu *menu)
+static void print_symbol(FILE *out, struct menu *menu)
{
struct symbol *sym = menu->sym;
struct property *prop;
if (sym_is_choice(sym))
- fprintf(out, "choice\n");
+ fprintf(out, "\nchoice\n");
else
- fprintf(out, "config %s\n", sym->name);
+ fprintf(out, "\nconfig %s\n", sym->name);
switch (sym->type) {
case S_BOOLEAN:
fputs(" boolean\n", out);
@@ -636,6 +656,30 @@ void print_symbol(FILE *out, struct menu *menu)
case P_CHOICE:
fputs(" #choice value\n", out);
break;
+ case P_SELECT:
+ fputs( " select ", out);
+ expr_fprint(prop->expr, out);
+ if (prop->value) {
+ fputs(" (value=", out);
+ expr_fprint(prop->value, out);
+ fputc(')', out);
+ }
+ if (!expr_is_yes(prop->visible.expr)) {
+ fputs(" if ", out);
+ expr_fprint(prop->visible.expr, out);
+ }
+ fputc('\n', out);
+ break;
+ case P_RANGE:
+ fputs( " range ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_MENU:
+ fputs( " menu ", out);
+ print_quoted_string(out, prop->text);
+ fputc('\n', out);
+ break;
default:
fprintf(out, " unknown prop %d!\n", prop->type);
break;
@@ -647,7 +691,6 @@ void print_symbol(FILE *out, struct menu *menu)
menu->help[len] = 0;
fprintf(out, " help\n%s\n", menu->help);
}
- fputc('\n', out);
}
void zconfdump(FILE *out)
@@ -680,7 +723,6 @@ void zconfdump(FILE *out)
expr_fprint(prop->visible.expr, out);
fputc('\n', out);
}
- fputs("\n", out);
}
if (menu->list)
@@ -698,7 +740,7 @@ void zconfdump(FILE *out)
}
}
-#include "lex.zconf.c"
+#include "zconf.lex.c"
#include "util.c"
#include "confdata.c"
#include "expr.c"