X-Git-Url: https://jxself.org/git/?p=carl9170fw.git;a=blobdiff_plain;f=config%2Fzconf.l;h=c52cce8b3751bb4d034e0a68ac13aa46188647aa;hp=052a9864b7ec5bd2a5b09f3313f10408d8b3538e;hb=e017a914b2679d669e201cc76f812b641aa7eea3;hpb=7bbbd919c36e802ac66320b3ed1c212487ab3f2d diff --git a/config/zconf.l b/config/zconf.l index 052a986..c52cce8 100644 --- a/config/zconf.l +++ b/config/zconf.l @@ -1,11 +1,11 @@ -%option nostdinit noyywrap never-interactive full ecs -%option 8bit nodefault yylineno -%x COMMAND HELP STRING PARAM ASSIGN_VAL -%{ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ +%option nostdinit noyywrap never-interactive full ecs +%option 8bit nodefault yylineno +%x ASSIGN_VAL HELP STRING +%{ #include #include @@ -15,6 +15,7 @@ #include #include "lkc.h" +#include "zconf.tab.h" #define YY_DECL static int yylex1(void) @@ -87,45 +88,73 @@ n [A-Za-z0-9_-] int str = 0; int ts, i; -[ \t]*#.*\n | -[ \t]*\n { - return T_EOL; -} -[ \t]*#.* -. { - unput(yytext[0]); - BEGIN(COMMAND); -} - - -{ - {n}+ { - const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); - if (id && id->flags & TF_COMMAND) { - BEGIN(PARAM); - return id->token; - } - alloc_string(yytext, yyleng); - yylval.string = text; - return T_WORD; - } - ({n}|$)+ { - /* this token includes at least one '$' */ - yylval.string = expand_token(yytext, yyleng); - if (strlen(yylval.string)) - return T_WORD; - free(yylval.string); - } - "=" return T_EQUAL; - ":=" return T_COLON_EQUAL; - "+=" return T_PLUS_EQUAL; - [[:blank:]]+ - . warn_ignored_character(*yytext); - \n { - BEGIN(INITIAL); - return T_EOL; - } -} +#.* /* ignore comment */ +[ \t]* /* whitespaces */ +\\\n /* escaped new line */ +\n return T_EOL; +"allnoconfig_y" return T_ALLNOCONFIG_Y; +"bool" return T_BOOL; +"choice" return T_CHOICE; +"comment" return T_COMMENT; +"config" return T_CONFIG; +"def_bool" return T_DEF_BOOL; +"def_tristate" return T_DEF_TRISTATE; +"default" return T_DEFAULT; +"defconfig_list" return T_DEFCONFIG_LIST; +"depends" return T_DEPENDS; +"endchoice" return T_ENDCHOICE; +"endif" return T_ENDIF; +"endmenu" return T_ENDMENU; +"help"|"---help---" return T_HELP; +"hex" return T_HEX; +"if" return T_IF; +"imply" return T_IMPLY; +"int" return T_INT; +"mainmenu" return T_MAINMENU; +"menu" return T_MENU; +"menuconfig" return T_MENUCONFIG; +"modules" return T_MODULES; +"on" return T_ON; +"option" return T_OPTION; +"optional" return T_OPTIONAL; +"prompt" return T_PROMPT; +"range" return T_RANGE; +"select" return T_SELECT; +"source" return T_SOURCE; +"string" return T_STRING; +"tristate" return T_TRISTATE; +"visible" return T_VISIBLE; +"||" return T_OR; +"&&" return T_AND; +"=" return T_EQUAL; +"!=" return T_UNEQUAL; +"<" return T_LESS; +"<=" return T_LESS_EQUAL; +">" return T_GREATER; +">=" return T_GREATER_EQUAL; +"!" return T_NOT; +"(" return T_OPEN_PAREN; +")" return T_CLOSE_PAREN; +":=" return T_COLON_EQUAL; +"+=" return T_PLUS_EQUAL; +\"|\' { + str = yytext[0]; + new_string(); + BEGIN(STRING); + } +{n}+ { + alloc_string(yytext, yyleng); + yylval.string = text; + return T_WORD; + } +({n}|$)+ { + /* this token includes at least one '$' */ + yylval.string = expand_token(yytext, yyleng); + if (strlen(yylval.string)) + return T_WORD; + free(yylval.string); + } +. warn_ignored_character(*yytext); { [^[:blank:]\n]+.* { @@ -137,49 +166,6 @@ n [A-Za-z0-9_-] . } -{ - "modules" return T_MODULES; - "defconfig_list" return T_DEFCONFIG_LIST; - "allnoconfig_y" return T_ALLNOCONFIG_Y; - "&&" return T_AND; - "||" return T_OR; - "(" return T_OPEN_PAREN; - ")" return T_CLOSE_PAREN; - "!" return T_NOT; - "=" return T_EQUAL; - "!=" return T_UNEQUAL; - "<=" return T_LESS_EQUAL; - ">=" return T_GREATER_EQUAL; - "<" return T_LESS; - ">" return T_GREATER; - \"|\' { - str = yytext[0]; - new_string(); - BEGIN(STRING); - } - \n BEGIN(INITIAL); return T_EOL; - {n}+ { - const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); - if (id && id->flags & TF_PARAM) { - return id->token; - } - alloc_string(yytext, yyleng); - yylval.string = text; - return T_WORD; - } - ({n}|$)+ { - /* this token includes at least one '$' */ - yylval.string = expand_token(yytext, yyleng); - if (strlen(yylval.string)) - return T_WORD; - free(yylval.string); - } - #.* /* comment */ - \\\n ; - [[:blank:]]+ - . warn_ignored_character(*yytext); -} - { "$".* append_expanded_string(yytext); [^$'"\\\n]+ { @@ -190,7 +176,7 @@ n [A-Za-z0-9_-] } \'|\" { if (str == yytext[0]) { - BEGIN(PARAM); + BEGIN(INITIAL); yylval.string = text; return T_WORD_QUOTE; } else