diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-09-30 14:13:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 14:13:39 +0200 |
commit | 6a8d6246f603a372d557ab026670ae42bad558b0 (patch) | |
tree | d6a54bad48390ed66322cf91e27da8e08f99d7a6 /src | |
parent | fd01c48d34d8caa98c3287f7736cf1e7b79c97b0 (diff) | |
parent | f14660d5e20df07d7b32d7658c83a76c713bc915 (diff) |
Merge pull request #5307 from Radvendii/master
reset yylloc when yyless(0) is called
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/lexer.l | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l index 8ad6a1957..51593eccd 100644 --- a/src/libexpr/lexer.l +++ b/src/libexpr/lexer.l @@ -28,6 +28,8 @@ using namespace nix; namespace nix { +// backup to recover from yyless(0) +YYLTYPE prev_yylloc; static void initLoc(YYLTYPE * loc) { @@ -38,6 +40,8 @@ static void initLoc(YYLTYPE * loc) static void adjustLoc(YYLTYPE * loc, const char * s, size_t len) { + prev_yylloc = *loc; + loc->first_line = loc->last_line; loc->first_column = loc->last_column; @@ -210,6 +214,7 @@ or { return OR_KW; } {HPATH_START}\$\{ { PUSH_STATE(PATH_START); yyless(0); + *yylloc = prev_yylloc; } <PATH_START>{PATH_SEG} { @@ -265,6 +270,7 @@ or { return OR_KW; } context (it may be ')', ';', or something of that sort) */ POP_STATE(); yyless(0); + *yylloc = prev_yylloc; return PATH_END; } |