-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libexpr: Rearrange lexer files so that yylex_init_extra can be found
- Loading branch information
Showing
3 changed files
with
49 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "lexer-tab.hh" | ||
#include "lexer-helpers.hh" | ||
#include "parser-tab.hh" | ||
|
||
void nix::lexer::internal::initLoc(YYLTYPE * loc) | ||
{ | ||
loc->first_line = loc->last_line = 0; | ||
loc->first_column = loc->last_column = 0; | ||
} | ||
|
||
void nix::lexer::internal::adjustLoc(yyscan_t yyscanner, YYLTYPE * loc, const char * s, size_t len) | ||
{ | ||
loc->stash(); | ||
|
||
LexerState & lexerState = *yyget_extra(yyscanner); | ||
|
||
if (lexerState.docCommentDistance == 1) { | ||
// Preceding token was a doc comment. | ||
ParserLocation doc; | ||
doc.first_column = lexerState.lastDocCommentLoc.first_column; | ||
ParserLocation docEnd; | ||
docEnd.first_column = lexerState.lastDocCommentLoc.last_column; | ||
DocComment docComment{lexerState.at(doc), lexerState.at(docEnd)}; | ||
PosIdx locPos = lexerState.at(*loc); | ||
lexerState.positionToDocComment.emplace(locPos, docComment); | ||
} | ||
lexerState.docCommentDistance++; | ||
|
||
loc->first_column = loc->last_column; | ||
loc->last_column += len; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
namespace nix::lexer::internal { | ||
|
||
void initLoc(YYLTYPE * loc); | ||
|
||
void adjustLoc(yyscan_t yyscanner, YYLTYPE * loc, const char * s, size_t len); | ||
|
||
} // namespace nix::lexer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters