2 ##############################################################################
4 # this file list token (rsv-word/signature), normal word, quated string, and
5 # append processing code after it if it needed.
6 # generally, those content should be defined:
7 # charset: fundamental char set name.
8 # blank/newline: ignore blank, or recognized in other defination. record
11 # maskchar: char of "\". some will process it in quated string, but some will
12 # process it in code as a mask char.
14 # symbol: it can be used for variable name.
15 # rsv-word(token): some fixed word defined as token.
16 # signature(token): punct char set.
17 # quatedstr: quated string with ", ', `.
18 # specialchar: such as $ in shell.
19 # EOF: file terminator processing.
20 # <some-others>: some particular content.
21 # rsv-word/signature/specialchar can be defined in other place. in code, or
22 # another lxr define file.
23 # lexer processing variables define.
24 # yytext, yyleng: current matching string pointer
27 # unput(yytext[0]): put a char back to original processing content.
28 # BEGIN(COMMAND): entering state. INITIAL is the default state.
29 ##############################################################################
32 // define T_WORD, T_TOKEN
52 * comment, sh-lang and c style.
65 /* C89 style comment */
68 //append_string(yytext, yyleng);
69 if (strstr(yytext, "\n") == 0)
80 /* if comment is multi line, return as a T_EOL. */
85 // append_string("*", 1);
89 // append_string("*", 1);
98 * signature token define.
100 "<" { last="<"; return T_LANGLE; }
101 ">" { last=">"; return T_RANGLE; }
102 "{" { last="{"; return T_LBRACE; }
103 "}" { last="}"; return T_RBRACE; }
104 "[" { last="["; return T_LBRACKET; }
105 "]" { last="]"; return T_RBRACKET; }
108 * signature token define.
111 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
112 current_pos.file = current_file;
113 current_pos.lineno = yylineno;
114 if (id && id->flags & TF_COMMAND) {
118 alloc_string(yytext, yyleng);
119 yylval.string = text;
124 * symbol word or rsv-word.
127 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
128 current_pos.file = current_file;
129 current_pos.lineno = yylineno;
130 if (id && id->flags & TF_COMMAND) {
134 alloc_string(yytext, yyleng);
135 yylval.string = text;
143 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
144 current_pos.file = current_file;
145 current_pos.lineno = yylineno;
146 if (id && id->flags & TF_COMMAND) {
150 alloc_string(yytext, yyleng);
151 yylval.string = text;
157 * text without blanks, and include none-blank display char.
159 [[:space:]]{t}+[[:space:]] {
160 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
161 current_pos.file = current_file;
162 current_pos.lineno = yylineno;
163 if (id && id->flags & TF_COMMAND) {
167 alloc_string(yytext, yyleng);
168 yylval.string = text;
172 . warn_ignored_character(*yytext);
187 /* single line string just for symbol */
190 append_string(yytext, yyleng);
193 /* '\' mask signature */
194 append_string(yytext + 1, yyleng - 1);
197 if (str == yytext[0]) {
199 yylval.string = text;
203 append_string(yytext, 1);
211 * multi-line string for code block.
212 * entering this state by function enter_state("BLOCK").
214 [[:space:]]\{[[:space:]] {
215 if ((strcmp (last, ">") == 0)
217 // BRACE in state define
223 // it's a response code of lex define.
226 append_string("{\n", 2);
232 * entering from "[[:space:]]\{[[:space:]]", and end with
233 * "[[:space:]]\}[[:space:]]". append string with "[^\{\}]*".
234 * since the single "{" or "}" should be recognized, this
235 * will avoid "}" mis-matching with multi "{}" pair in block.
236 * so, the ending "}" should be matching with
237 * "[^\{\}]*[[:space:]]\}[[:space:]]". if mathcing "[^\{\}]*"
238 * and "[[:space:]]\}[[:space:]]" seperatly, "[^\{\}]*" will
239 * matching with "[[:space:]]", which is before "}", then,
240 * "[[:space:]]\}[[:space:]]" is not matched, but "}" is matched.
241 * if put checking code in "}" process code,
245 * code block is terminated with a } and a newline, whatever
246 * there are comments between them.
248 [^\{\}]*[[:space:]]\}[[:space:]]*(\#[^\n]*)?\n {
249 append_string(yytext, yyleng);
260 append_string(yytext, yyleng);
263 append_string("{", 1);
270 * should not entering here.
271 * it means there are no "[[:space:]]" char matching before "{".
272 * or, it will matching the first item of syntax define.
274 //dbgout("there must be blank char before and after '}'.\n");
275 append_string("\n}", 2);
282 append_string("}", 1);