schema_editor/comdel/parser/token.h

145 lines
1.9 KiB
C++

#ifndef TOKEN_H
#define TOKEN_H
#include <string>
#include <map>
struct Position {
unsigned fileId;
unsigned line;
unsigned col;
unsigned offset;
Position();
Position(unsigned fileId, unsigned line, unsigned col, unsigned offset);
};
/** Location of an ast node inside the source **/
struct Span {
/** beginning (low) position **/
Position lo;
/** end (high) position **/
Position hi;
Span();
Span(Position lo, Position hi);
Span(Position lo);
Span to(const Span& span) const;
};
enum class TokenType {
COLON,
SEMICOLON,
LBRACE,
RBRACE,
LPAREN,
RPAREN,
LBRACKET,
RBRACKET,
LT,
GT,
KEYWORD,
IDENTIFIER,
NUMBER,
STRING,
NOT,
COMMA,
DOT,
COLOR,
EQUALS,
COMMENT,
WHITESPACE,
IF,
ELSE,
DEFAULT,
// BOOLEAN VALUE
TRUE,
FALSE,
// NULL
NIL,
// KEYWORDS
KW_NAME,
KW_INFO,
KW_HEADER,
KW_COMPONENT_HEADER,
KW_DIRECTORY,
KW_LIBRARY,
KW_ADDRESS,
KW_COMPONENT,
KW_MESSAGES,
KW_INSTANCE_NAME,
KW_COUNT,
KW_DISPLAY,
KW_PIN,
KW_TOOLTIP,
KW_CONNECTION,
KW_ATTRIBUTE,
KW_SOURCE,
KW_POPUP,
KW_RULE,
KW_TITLE,
KW_TEXT,
KW_BUS,
KW_WIRES,
KW_ENUMERATED,
KW_WIRE,
KW_INSTANCE,
KW_SCHEMA,
KW_POSITION,
KW_SIZE,
KW_UNKNOWN,
// TYPES
INT_TYPE,
BOOL_TYPE,
STRING_TYPE,
WIRE_TYPE,
// WIRE TYPES
WIRE_DEFAULT,
WIRE_AND,
WIRE_OR,
R_WIRE,
// PIN_TYPES
PIN_IN,
PIN_OUT,
PIN_IN_OUT,
// COMPONENT TYPES
CT_MEMORY,
CT_PROCESSOR,
// ACTION TYPES
ERROR,
WARNING,
// WIRE SETTINGS
HIDDEN,
TERMINATE_WITH,
// OTHER
END_OF_FILE
};
struct Token {
TokenType type;
Span span;
std::string text;
Token(TokenType type, Span span, std::string text);
};
#endif // TOKEN_H