diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-11 06:00:48 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-12 10:16:24 -0500 |
commit | 21c5ecf60472be9f1b5bfe0b94870bef93db4202 (patch) | |
tree | e61a38ee50c5fa7fdd226bdf4fa5fdf1db15b36b /scripts/kconfig | |
parent | be3c8075978a420b6eae944250bf336aa11d4964 (diff) |
kconfig: refactor pattern matching in STRING state
Here, similar matching patters are duplicated in order to look ahead
the '\n' character. If the next character is '\n', the lexer returns
T_WORD_QUOTE because it must be prepared to return T_EOL at the next
match.
Use unput('\n') trick to reduce the code duplication.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/zconf.l | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 709b774f2404..b7bc164fdf00 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -182,19 +182,9 @@ n [A-Za-z0-9_-] | |||
182 | 182 | ||
183 | <STRING>{ | 183 | <STRING>{ |
184 | "$".* append_expanded_string(yytext); | 184 | "$".* append_expanded_string(yytext); |
185 | [^$'"\\\n]+/\n { | ||
186 | append_string(yytext, yyleng); | ||
187 | yylval.string = text; | ||
188 | return T_WORD_QUOTE; | ||
189 | } | ||
190 | [^$'"\\\n]+ { | 185 | [^$'"\\\n]+ { |
191 | append_string(yytext, yyleng); | 186 | append_string(yytext, yyleng); |
192 | } | 187 | } |
193 | \\.?/\n { | ||
194 | append_string(yytext + 1, yyleng - 1); | ||
195 | yylval.string = text; | ||
196 | return T_WORD_QUOTE; | ||
197 | } | ||
198 | \\.? { | 188 | \\.? { |
199 | append_string(yytext + 1, yyleng - 1); | 189 | append_string(yytext + 1, yyleng - 1); |
200 | } | 190 | } |
@@ -210,8 +200,10 @@ n [A-Za-z0-9_-] | |||
210 | fprintf(stderr, | 200 | fprintf(stderr, |
211 | "%s:%d:warning: multi-line strings not supported\n", | 201 | "%s:%d:warning: multi-line strings not supported\n", |
212 | zconf_curname(), zconf_lineno()); | 202 | zconf_curname(), zconf_lineno()); |
203 | unput('\n'); | ||
213 | BEGIN(INITIAL); | 204 | BEGIN(INITIAL); |
214 | return T_EOL; | 205 | yylval.string = text; |
206 | return T_WORD_QUOTE; | ||
215 | } | 207 | } |
216 | <<EOF>> { | 208 | <<EOF>> { |
217 | BEGIN(INITIAL); | 209 | BEGIN(INITIAL); |