#include "token.h" #include 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)) {} const std::map KeywordType::keywords = { {"@name", NAME}, {"@info", INFO}, {"@header", HEADER}, {"@directory", DIRECTORY}, {"@library", LIBRARY}, {"@address", ADDRESS}, {"@component", COMPONENT}, {"@messages", MESSAGES}, {"@instanceName", INSTANCE_NAME}, {"@count", COUNT}, {"@display", DISPLAY}, {"@pin", PIN}, {"@tooltip", TOOLTIP}, {"@connection", CONNECTION}, {"@attribute", ATTRIBUTE}, {"@source", SOURCE}, {"@popup", POPUP}, {"@rule", RULE}, {"@title", TITLE}, {"@text", TEXT}, {"@bus", BUS}, {"@wires", WIRES}, {"@enumerated", ENUMERATED}, {"@wire", WIRE}, {"@instance", INSTANCE}, {"@schema", SCHEMA}, {"@position", POSITION}, {"@size", SIZE} };