2024-07-09 16:39:24 +03:00
|
|
|
#include "lexer-tab.hh"
|
|
|
|
#include "lexer-helpers.hh"
|
|
|
|
#include "parser-tab.hh"
|
|
|
|
|
|
|
|
void nix::lexer::internal::initLoc(YYLTYPE * loc)
|
|
|
|
{
|
2024-07-11 14:06:39 +03:00
|
|
|
loc->beginOffset = loc->endOffset = 0;
|
2024-07-09 16:39:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2024-07-11 14:06:39 +03:00
|
|
|
doc.beginOffset = lexerState.lastDocCommentLoc.beginOffset;
|
2024-07-09 16:39:24 +03:00
|
|
|
ParserLocation docEnd;
|
2024-07-11 14:06:39 +03:00
|
|
|
docEnd.beginOffset = lexerState.lastDocCommentLoc.endOffset;
|
2024-07-09 16:39:24 +03:00
|
|
|
DocComment docComment{lexerState.at(doc), lexerState.at(docEnd)};
|
|
|
|
PosIdx locPos = lexerState.at(*loc);
|
|
|
|
lexerState.positionToDocComment.emplace(locPos, docComment);
|
|
|
|
}
|
|
|
|
lexerState.docCommentDistance++;
|
|
|
|
|
2024-07-11 14:06:39 +03:00
|
|
|
loc->beginOffset = loc->endOffset;
|
|
|
|
loc->endOffset += len;
|
2024-07-09 16:39:24 +03:00
|
|
|
}
|