mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
libexpr: Rename "column" fields to offset
... because that's what they are.
This commit is contained in:
parent
77e9f9ee82
commit
71cb8bf509
4 changed files with 21 additions and 21 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
void nix::lexer::internal::initLoc(YYLTYPE * loc)
|
void nix::lexer::internal::initLoc(YYLTYPE * loc)
|
||||||
{
|
{
|
||||||
loc->first_column = loc->last_column = 0;
|
loc->beginOffset = loc->endOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nix::lexer::internal::adjustLoc(yyscan_t yyscanner, YYLTYPE * loc, const char * s, size_t len)
|
void nix::lexer::internal::adjustLoc(yyscan_t yyscanner, YYLTYPE * loc, const char * s, size_t len)
|
||||||
|
@ -16,15 +16,15 @@ void nix::lexer::internal::adjustLoc(yyscan_t yyscanner, YYLTYPE * loc, const ch
|
||||||
if (lexerState.docCommentDistance == 1) {
|
if (lexerState.docCommentDistance == 1) {
|
||||||
// Preceding token was a doc comment.
|
// Preceding token was a doc comment.
|
||||||
ParserLocation doc;
|
ParserLocation doc;
|
||||||
doc.first_column = lexerState.lastDocCommentLoc.first_column;
|
doc.beginOffset = lexerState.lastDocCommentLoc.beginOffset;
|
||||||
ParserLocation docEnd;
|
ParserLocation docEnd;
|
||||||
docEnd.first_column = lexerState.lastDocCommentLoc.last_column;
|
docEnd.beginOffset = lexerState.lastDocCommentLoc.endOffset;
|
||||||
DocComment docComment{lexerState.at(doc), lexerState.at(docEnd)};
|
DocComment docComment{lexerState.at(doc), lexerState.at(docEnd)};
|
||||||
PosIdx locPos = lexerState.at(*loc);
|
PosIdx locPos = lexerState.at(*loc);
|
||||||
lexerState.positionToDocComment.emplace(locPos, docComment);
|
lexerState.positionToDocComment.emplace(locPos, docComment);
|
||||||
}
|
}
|
||||||
lexerState.docCommentDistance++;
|
lexerState.docCommentDistance++;
|
||||||
|
|
||||||
loc->first_column = loc->last_column;
|
loc->beginOffset = loc->endOffset;
|
||||||
loc->last_column += len;
|
loc->endOffset += len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,8 +287,8 @@ or { return OR_KW; }
|
||||||
\/\*\*[^/*]([^*]|\*+[^*/])*\*+\/ /* doc comments */ {
|
\/\*\*[^/*]([^*]|\*+[^*/])*\*+\/ /* doc comments */ {
|
||||||
LexerState & lexerState = *yyget_extra(yyscanner);
|
LexerState & lexerState = *yyget_extra(yyscanner);
|
||||||
lexerState.docCommentDistance = 0;
|
lexerState.docCommentDistance = 0;
|
||||||
lexerState.lastDocCommentLoc.first_column = yylloc->first_column;
|
lexerState.lastDocCommentLoc.beginOffset = yylloc->beginOffset;
|
||||||
lexerState.lastDocCommentLoc.last_column = yylloc->last_column;
|
lexerState.lastDocCommentLoc.endOffset = yylloc->endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,20 +22,20 @@ struct StringToken
|
||||||
|
|
||||||
struct ParserLocation
|
struct ParserLocation
|
||||||
{
|
{
|
||||||
int first_column;
|
int beginOffset;
|
||||||
int last_column;
|
int endOffset;
|
||||||
|
|
||||||
// backup to recover from yyless(0)
|
// backup to recover from yyless(0)
|
||||||
int stashed_first_column, stashed_last_column;
|
int stashedBeginOffset, stashedEndOffset;
|
||||||
|
|
||||||
void stash() {
|
void stash() {
|
||||||
stashed_first_column = first_column;
|
stashedBeginOffset = beginOffset;
|
||||||
stashed_last_column = last_column;
|
stashedEndOffset = endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unstash() {
|
void unstash() {
|
||||||
first_column = stashed_first_column;
|
beginOffset = stashedBeginOffset;
|
||||||
last_column = stashed_last_column;
|
endOffset = stashedEndOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Latest doc comment position, or 0. */
|
/** Latest doc comment position, or 0. */
|
||||||
|
@ -308,12 +308,12 @@ inline Expr * ParserState::stripIndentation(const PosIdx pos,
|
||||||
|
|
||||||
inline PosIdx LexerState::at(const ParserLocation & loc)
|
inline PosIdx LexerState::at(const ParserLocation & loc)
|
||||||
{
|
{
|
||||||
return positions.add(origin, loc.first_column);
|
return positions.add(origin, loc.beginOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PosIdx ParserState::at(const ParserLocation & loc)
|
inline PosIdx ParserState::at(const ParserLocation & loc)
|
||||||
{
|
{
|
||||||
return positions.add(origin, loc.first_column);
|
return positions.add(origin, loc.beginOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,13 @@
|
||||||
do \
|
do \
|
||||||
if (N) \
|
if (N) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
(Current).beginOffset = YYRHSLOC (Rhs, 1).beginOffset; \
|
||||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
(Current).endOffset = YYRHSLOC (Rhs, N).endOffset; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).first_column = (Current).last_column = \
|
(Current).beginOffset = (Current).endOffset = \
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
YYRHSLOC (Rhs, 0).endOffset; \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ using namespace nix;
|
||||||
void yyerror(YYLTYPE * loc, yyscan_t scanner, ParserState * state, const char * error)
|
void yyerror(YYLTYPE * loc, yyscan_t scanner, ParserState * state, const char * error)
|
||||||
{
|
{
|
||||||
if (std::string_view(error).starts_with("syntax error, unexpected end of file")) {
|
if (std::string_view(error).starts_with("syntax error, unexpected end of file")) {
|
||||||
loc->first_column = loc->last_column;
|
loc->beginOffset = loc->endOffset;
|
||||||
}
|
}
|
||||||
throw ParseError({
|
throw ParseError({
|
||||||
.msg = HintFmt(error),
|
.msg = HintFmt(error),
|
||||||
|
|
Loading…
Reference in a new issue