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
56 * comment, sh-lang and c style.
69 /* C89 style comment */
72 //append_string(yytext, yyleng);
73 if (strstr(yytext, "\n") == 0)
84 /* if comment is multi line, return as a T_EOL. */
89 // append_string("*", 1);
93 // append_string("*", 1);
102 * signature token define.
105 "<" { last="<"; return T_LANGLE; }
106 ">" { last=">"; return T_RANGLE; }
107 "{" { last="{"; return T_LBRACE; }
108 "}" { last="}"; return T_RBRACE; }
109 "[" { last="["; return T_LBRACKET; }
110 "]" { last="]"; return T_RBRACKET; }
114 * signature token define.
117 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
118 current_pos.file = current_file;
119 current_pos.lineno = yylineno;
120 if (id && id->flags & TF_COMMAND) {
124 alloc_string(yytext, yyleng);
125 yylval.string = text;
130 * symbol word or rsv-word.
133 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
134 current_pos.file = current_file;
135 current_pos.lineno = yylineno;
136 if (id && id->flags & TF_COMMAND) {
140 alloc_string(yytext, yyleng);
141 yylval.string = text;
149 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
150 current_pos.file = current_file;
151 current_pos.lineno = yylineno;
152 if (id && id->flags & TF_COMMAND) {
156 alloc_string(yytext, yyleng);
157 yylval.string = text;
163 * text without blanks, and include none-blank display char.
165 [[:space:]]{t}+[[:space:]] {
166 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
167 current_pos.file = current_file;
168 current_pos.lineno = yylineno;
169 if (id && id->flags & TF_COMMAND) {
173 alloc_string(yytext, yyleng);
174 yylval.string = text;
178 . warn_ignored_character(*yytext);
191 /* single line string just for symbol */
194 append_string(yytext, yyleng);
197 /* '\' mask signature */
198 append_string(yytext + 1, yyleng - 1);
201 if (str == yytext[0]) {
203 yylval.string = text;
207 append_string(yytext, 1);
215 * multi-line string for code block.
216 * entering this state by function enter_state("BLOCK").
218 [[:space:]]\{[[:space:]] {
219 if ((strcmp (last, ">") == 0)
221 // BRACE in state define
227 // it's a response code of lex define.
230 append_string("{\n", 2);
236 * entering from "[[:space:]]\{[[:space:]]", and end with
237 * "[[:space:]]\}[[:space:]]". append string with "[^\{\}]*".
238 * since the single "{" or "}" should be recognized, this
239 * will avoid "}" mis-matching with multi "{}" pair in block.
240 * so, the ending "}" should be matching with
241 * "[^\{\}]*[[:space:]]\}[[:space:]]". if mathcing "[^\{\}]*"
242 * and "[[:space:]]\}[[:space:]]" seperatly, "[^\{\}]*" will
243 * matching with "[[:space:]]", which is before "}", then,
244 * "[[:space:]]\}[[:space:]]" is not matched, but "}" is matched.
245 * if put checking code in "}" process code,
249 * code block is terminated with a } and a newline, whatever
250 * there are comments between them.
252 [^\{\}]*[[:space:]]\}[[:space:]]*(\#[^\n]*)?\n {
253 append_string(yytext, yyleng);
264 append_string(yytext, yyleng);
267 append_string("{", 1);
274 * should not entering here.
275 * it means there are no "[[:space:]]" char matching before "{".
276 * or, it will matching the first item of syntax define.
278 //dbgout("there must be blank char before and after '}'.\n");
279 append_string("\n}", 2);
286 append_string("}", 1);