schema_editor/comdel/parser/token.cpp

36 lines
701 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 Span(this->lo, span.hi);
}
Token::Token(TokenType type, Span span, std::string text)
: type(type)
, span(std::move(span))
, text(std::move(text))
{}