mirror of
https://github.com/NixOS/nix
synced 2025-06-28 05:21:16 +02:00
libexpr: Rearrange lexer files so that yylex_init_extra can be found
This commit is contained in:
parent
7fae378835
commit
e68234c4f9
4 changed files with 51 additions and 34 deletions
31
src/libexpr/lexer-helpers.cc
Normal file
31
src/libexpr/lexer-helpers.cc
Normal file
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue