schema_editor/comdel/parser/token.cpp

27 lines
704 B
C++
Raw Normal View History

2022-03-29 19:31:45 +00:00
#include "token.h"
#include <string>
Position::Position()
2022-05-27 06:18:17 +00:00
: fileId(0), line(0), col(0), offset(0) {}
2022-03-29 19:31:45 +00:00
Position::Position(unsigned file, unsigned line, unsigned col, unsigned offset)
2022-05-27 06:18:17 +00:00
: fileId(file), line(line), col(col), offset(offset) {}
2022-03-29 19:31:45 +00:00
Span::Span()
2022-05-27 06:18:17 +00:00
: lo(0, 0, 0, 0), hi(0, 0, 0, 0) {}
2022-03-29 19:31:45 +00:00
Span::Span(Position begin, Position end)
2022-05-27 06:18:17 +00:00
: lo(begin), hi(end) {}
2022-03-29 19:31:45 +00:00
Span::Span(Position begin)
2022-05-27 06:18:17 +00:00
: Span(begin, Position(begin.fileId, begin.line, begin.col + 1, begin.offset + 1)) {}
2022-03-29 19:31:45 +00:00
2022-05-27 06:18:17 +00:00
Span Span::to(const Span &span) const {
return {this->lo, span.hi};
2022-03-29 19:31:45 +00:00
}
Token::Token(TokenType type, Span span, std::string text)
2022-05-27 06:18:17 +00:00
: type(type), span(span), text(std::move(text)) {}