schema_editor/comdel/parser/token.h

148 lines
1.9 KiB
C
Raw Permalink Normal View History

2022-03-29 19:31:45 +00:00
#ifndef TOKEN_H
#define TOKEN_H
#include <string>
#include <map>
struct Position {
unsigned fileId;
unsigned line;
unsigned col;
unsigned offset;
Position();
2022-05-27 06:18:17 +00:00
2022-03-29 19:31:45 +00:00
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();
2022-05-27 06:18:17 +00:00
2022-03-29 19:31:45 +00:00
Span(Position lo, Position hi);
2022-05-27 06:18:17 +00:00
2022-03-29 19:31:45 +00:00
Span(Position lo);
2022-05-27 06:18:17 +00:00
Span to(const Span &span) const;
2022-03-29 19:31:45 +00:00
};
enum class TokenType {
COLON,
SEMICOLON,
LBRACE,
RBRACE,
LPAREN,
RPAREN,
LBRACKET,
RBRACKET,
LT,
GT,
KEYWORD,
IDENTIFIER,
NUMBER,
STRING,
NOT,
COMMA,
DOT,
COLOR,
EQUALS,
COMMENT,
WHITESPACE,
2022-03-29 21:08:55 +00:00
IF,
ELSE,
DEFAULT,
// BOOLEAN VALUE
TRUE,
FALSE,
// NULL
NIL,
2022-03-29 21:08:55 +00:00
// KEYWORDS
KW_NAME,
KW_INFO,
KW_HEADER,
2022-05-15 23:02:34 +00:00
KW_COMPONENT_HEADER,
2022-03-29 21:08:55 +00:00
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,
2022-06-14 19:27:40 +00:00
KW_DISPLAY_NAME,
2022-03-29 19:31:45 +00:00
// TYPES
2022-03-29 21:08:55 +00:00
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,
2022-04-24 20:21:45 +00:00
// WIRE SETTINGS
HIDDEN,
TERMINATE_WITH,
2022-03-29 21:08:55 +00:00
// OTHER
END_OF_FILE
2022-03-29 19:31:45 +00:00
};
struct Token {
TokenType type;
Span span;
std::string text;
Token(TokenType type, Span span, std::string text);
};
#endif // TOKEN_H