summaryrefslogtreecommitdiffstats
path: root/scripts/tkparse.h
blob: 1ca16b1852e73e692fe2091c1572737245314da4 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * tkparse.h
 */

/*
 * Token types (mostly statement types).
 */

enum e_token
{
    token_UNKNOWN,
    token_bool, 
    token_choice_header,
    token_choice_item,
    token_comment, 
    token_define_bool,
    token_define_hex,
    token_define_int,
    token_define_string,
    token_define_tristate,
    token_dep_bool,
    token_dep_mbool,
    token_dep_tristate,
    token_else, 
    token_endmenu,
    token_fi, 
    token_hex,
    token_if, 
    token_int,
    token_mainmenu_name, 
    token_mainmenu_option, 
    token_source,
    token_string,
    token_then,
    token_tristate, 
    token_unset,
};

/*
 * Operator types for conditionals.
 */

enum operator
{
    op_eq,
    op_neq,
    op_and,
    op_and1,
    op_or,
    op_bang,
    op_lparen,
    op_rparen,
    op_constant,
    op_variable,
    op_true,
    op_false,
    op_nuked
};

/*
 * Conditions come in linked lists.
 * Some operators take strings:
 *
 *   op_constant   "foo"
 *   op_variable   "$ARCH", "$CONFIG_PMAC", "$CONFIG_EXPERIMENTAL"
 *
 * Most "$..." constructs refer to a variable which is defined somewhere
 * in the script.  Note that it is legal to test variables which are never
 * defined, such as variables that are meaningful only on other architectures.
 */

struct condition
{
    struct condition *	next;
    enum operator	op;
    const char *	str;		/* op_constant */
    int			nameindex;	/* op_variable */
};

/*
 * Dependency list for dep_bool, dep_mbool, dep_tristate
 */

struct dependency
{
    char *		name;
    struct dependency *	next;
};

/*
 * A statement from a config.in file
 */

struct kconfig
{
    struct kconfig *	next;
    enum e_token	token;
    int			nameindex;
    char *		label;
    char *		value;
    struct condition *	cond;
    struct dependency *	depend;		/* token_dep_tristate */
    struct kconfig *	cfg_parent;	/* token_choice_item */

    /* used only in tkgen.c */
    int			menu_number;
    int			menu_line;
    struct kconfig *	menu_next;
};

struct variable
{
    char *	name;
    char	defined;
    char	global_written;
};

extern struct variable vartable[];
extern int max_varnum;

/*
 * Prototypes
 */

extern void fix_conditionals ( struct kconfig * scfg );		/* tkcond.c */
extern void dump_tk_script   ( struct kconfig * scfg );		/* tkgen.c  */
extern int get_varnum        ( char * name );			/* tkparse.c */