trim
[build-config.git] / shlib / menuconfig-example.lxr
blob4ae6da4699aa90ef6d571c6bd40a292ade0158b2
2 #############################################
3 # example.lxr
4 #############################################
6 [lxr-charset]
7 n       [A-Za-z0-9_-]
9 [lxr-token]
11 [ \t]*#.*\n     |
12 [ \t]*\n        {
13         return T_EOL;
15 [ \t]*#.*
18 [ \t]+  {
19         BEGIN(COMMAND);
22 .       {
23         unput(yytext[0]);
24         BEGIN(COMMAND);
28 <COMMAND>{
29         {n}+    {
30                 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
31                 BEGIN(PARAM);
32                 current_pos.file = current_file;
33                 current_pos.lineno = yylineno;
34                 if (id && id->flags & TF_COMMAND) {
35                         yylval.id = id;
36                         return id->token;
37                 }
38                 alloc_string(yytext, yyleng);
39                 yylval.string = text;
40                 return T_WORD;
41         }
42         .       warn_ignored_character(*yytext);
43         \n      {
44                 BEGIN(INITIAL);
45                 return T_EOL;
46         }
49 <PARAM>{
50         "&&"    return T_AND;
51         "||"    return T_OR;
52         "("     return T_OPEN_PAREN;
53         ")"     return T_CLOSE_PAREN;
54         "!"     return T_NOT;
55         "="     return T_EQUAL;
56         "!="    return T_UNEQUAL;
57         "<="    return T_LESS_EQUAL;
58         ">="    return T_GREATER_EQUAL;
59         "<"     return T_LESS;
60         ">"     return T_GREATER;
61         \"|\'   {
62                 str = yytext[0];
63                 new_string();
64                 BEGIN(STRING);
65         }
66         \n      BEGIN(INITIAL); return T_EOL;
67         ({n}|[/.])+     {
68                 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
69                 if (id && id->flags & TF_PARAM) {
70                         yylval.id = id;
71                         return id->token;
72                 }
73                 alloc_string(yytext, yyleng);
74                 yylval.string = text;
75                 return T_WORD;
76         }
77         #.*     /* comment */
78         \\\n    ;
79         [[:blank:]]+
80         .       warn_ignored_character(*yytext);
81         <<EOF>> {
82                 BEGIN(INITIAL);
83         }
86 <STRING>{
87         [^'"\\\n]+/\n   {
88                 append_string(yytext, yyleng);
89                 yylval.string = text;
90                 return T_WORD_QUOTE;
91         }
92         [^'"\\\n]+      {
93                 append_string(yytext, yyleng);
94         }
95         \\.?/\n {
96                 append_string(yytext + 1, yyleng - 1);
97                 yylval.string = text;
98                 return T_WORD_QUOTE;
99         }
100         \\.?    {
101                 append_string(yytext + 1, yyleng - 1);
102         }
103         \'|\"   {
104                 if (str == yytext[0]) {
105                         BEGIN(PARAM);
106                         yylval.string = text;
107                         return T_WORD_QUOTE;
108                 } else
109                         append_string(yytext, 1);
110         }
111         \n      {
112                 fprintf(stderr,
113                         "%s:%d:warning: multi-line strings not supported\n",
114                         zconf_curname(), zconf_lineno());
115                 BEGIN(INITIAL);
116                 return T_EOL;
117         }
118         <<EOF>> {
119                 BEGIN(INITIAL);
120         }
123 <HELP>{
124         [ \t]+  {
125                 ts = 0;
126                 for (i = 0; i < yyleng; i++) {
127                         if (yytext[i] == '\t')
128                                 ts = (ts & ~7) + 8;
129                         else
130                                 ts++;
131                 }
132                 last_ts = ts;
133                 if (first_ts) {
134                         if (ts < first_ts) {
135                                 zconf_endhelp();
136                                 return T_HELPTEXT;
137                         }
138                         ts -= first_ts;
139                         while (ts > 8) {
140                                 append_string("        ", 8);
141                                 ts -= 8;
142                         }
143                         append_string("        ", ts);
144                 }
145         }
146         [ \t]*\n/[^ \t\n] {
147                 zconf_endhelp();
148                 return T_HELPTEXT;
149         }
150         [ \t]*\n        {
151                 append_string("\n", 1);
152         }
153         [^ \t\n].* {
154                 while (yyleng) {
155                         if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t'))
156                                 break;
157                         yyleng--;
158                 }
159                 append_string(yytext, yyleng);
160                 if (!first_ts)
161                         first_ts = last_ts;
162         }
163         <<EOF>> {
164                 zconf_endhelp();
165                 return T_HELPTEXT;
166         }
169 <<EOF>> {
170         if (current_file) {
171                 zconf_endfile();
172                 return T_EOL;
173         }
174         fclose(yyin);
175         yyterminate();