schema_editor/comdel/parser/token.cpp

27 lines
704 B
C++

#include "token.h"
#include <string>
Position::Position()
: fileId(0), line(0), col(0), offset(0) {}
Position::Position(unsigned file, unsigned line, unsigned col, unsigned offset)
: fileId(file), line(line), col(col), offset(offset) {}
Span::Span()
: lo(0, 0, 0, 0), hi(0, 0, 0, 0) {}
Span::Span(Position begin, Position end)
: lo(begin), hi(end) {}
Span::Span(Position begin)
: Span(begin, Position(begin.fileId, begin.line, begin.col + 1, begin.offset + 1)) {}
Span Span::to(const Span &span) const {
return {this->lo, span.hi};
}
Token::Token(TokenType type, Span span, std::string text)
: type(type), span(span), text(std::move(text)) {}