Skip to content

Commit 8b3af40

Browse files
committed
fix(libexpr/lexer): fix flex warning about default rule
We were getting this flex lexer warning during build: ``` ../src/libexpr/lexer.l:333: warning, -s option given but default rule can be matched ``` The lexer uses `%option nodefault` but the `PATH_START` state only had rules for specific patterns (`PATH_SEG` and `HPATH_START`) without a catch-all rule to handle unexpected input. Added a catch-all rule with `unreachable()`. This code path should never be reached in normal operation since `PATH_START` is only entered after matching `PATH_SEG` or `HPATH_START`, and we immediately rewind to re-parse those same patterns. The catch-all exists solely to satisfy flex's `%option nodefault` requirement.
1 parent da637a0 commit 8b3af40

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libexpr/lexer.l

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ or { return OR_KW; }
243243
return HPATH;
244244
}
245245

246+
<PATH_START>{ANY} |
247+
<PATH_START><<EOF>> {
248+
/* This should be unreachable: PATH_START is only entered after matching
249+
PATH_SEG or HPATH_START, and we rewind to re-parse those same patterns.
250+
This rule exists to satisfy flex's %option nodefault requirement. */
251+
unreachable();
252+
}
253+
246254
{PATH} {
247255
if (yytext[yyleng-1] == '/')
248256
PUSH_STATE(INPATH_SLASH);

0 commit comments

Comments
 (0)