1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

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.
This commit is contained in:
Bernardo Meurer Costa 2025-10-29 17:19:17 +00:00
parent da637a05da
commit 8b3af40006
No known key found for this signature in database

View file

@ -243,6 +243,14 @@ or { return OR_KW; }
return HPATH; return HPATH;
} }
<PATH_START>{ANY} |
<PATH_START><<EOF>> {
/* This should be unreachable: PATH_START is only entered after matching
PATH_SEG or HPATH_START, and we rewind to re-parse those same patterns.
This rule exists to satisfy flex's %option nodefault requirement. */
unreachable();
}
{PATH} { {PATH} {
if (yytext[yyleng-1] == '/') if (yytext[yyleng-1] == '/')
PUSH_STATE(INPATH_SLASH); PUSH_STATE(INPATH_SLASH);