174 lines
5.2 KiB
C
174 lines
5.2 KiB
C
// auto generated by meta.c
|
|
typedef enum {
|
|
TOK_EOF,
|
|
TOK_ERROR,
|
|
TOK_IDENT,
|
|
TOK_KEYWORD,
|
|
TOK_INT,
|
|
TOK_FLOAT,
|
|
TOK_CHAR,
|
|
TOK_STRING,
|
|
TOK_LPAREN,
|
|
TOK_RPAREN,
|
|
TOK_LBRACKET,
|
|
TOK_RBRACKET,
|
|
TOK_LBRACE,
|
|
TOK_RBRACE,
|
|
TOK_COMMA,
|
|
TOK_DOT,
|
|
TOK_ARROW,
|
|
TOK_ELLIPSIS,
|
|
TOK_COLON,
|
|
TOK_SEMICOLON,
|
|
TOK_QUESTION,
|
|
TOK_HASH,
|
|
TOK_HASHHASH,
|
|
TOK_PLUS,
|
|
TOK_MINUS,
|
|
TOK_STAR,
|
|
TOK_SLASH,
|
|
TOK_PERCENT,
|
|
TOK_INC,
|
|
TOK_DEC,
|
|
TOK_ASSIGN,
|
|
TOK_PLUS_ASSIGN,
|
|
TOK_MINUS_ASSIGN,
|
|
TOK_MUL_ASSIGN,
|
|
TOK_DIV_ASSIGN,
|
|
TOK_MOD_ASSIGN,
|
|
TOK_LSHIFT_ASSIGN,
|
|
TOK_RSHIFT_ASSIGN,
|
|
TOK_AND_ASSIGN,
|
|
TOK_XOR_ASSIGN,
|
|
TOK_OR_ASSIGN,
|
|
TOK_EQ,
|
|
TOK_NEQ,
|
|
TOK_LT,
|
|
TOK_LEQ,
|
|
TOK_GT,
|
|
TOK_GEQ,
|
|
TOK_NOT,
|
|
TOK_BITNOT,
|
|
TOK_BITAND,
|
|
TOK_BITOR,
|
|
TOK_BITXOR,
|
|
TOK_AND,
|
|
TOK_OR,
|
|
TOK_LSHIFT,
|
|
TOK_RSHIFT,
|
|
} Token_Kind;
|
|
char *token_to_op(Token_Kind kind) {
|
|
switch (kind) {
|
|
case TOK_LPAREN: return "(";
|
|
case TOK_RPAREN: return ")";
|
|
case TOK_LBRACKET: return "[";
|
|
case TOK_RBRACKET: return "]";
|
|
case TOK_LBRACE: return "{";
|
|
case TOK_RBRACE: return "}";
|
|
case TOK_COMMA: return ",";
|
|
case TOK_DOT: return ".";
|
|
case TOK_ARROW: return "->";
|
|
case TOK_ELLIPSIS: return "...";
|
|
case TOK_COLON: return ":";
|
|
case TOK_SEMICOLON: return ";";
|
|
case TOK_QUESTION: return "?";
|
|
case TOK_HASH: return "#";
|
|
case TOK_HASHHASH: return "##";
|
|
case TOK_PLUS: return "+";
|
|
case TOK_MINUS: return "-";
|
|
case TOK_STAR: return "*";
|
|
case TOK_SLASH: return "/";
|
|
case TOK_PERCENT: return "%";
|
|
case TOK_INC: return "++";
|
|
case TOK_DEC: return "--";
|
|
case TOK_ASSIGN: return "=";
|
|
case TOK_PLUS_ASSIGN: return "+=";
|
|
case TOK_MINUS_ASSIGN: return "-=";
|
|
case TOK_MUL_ASSIGN: return "*=";
|
|
case TOK_DIV_ASSIGN: return "/=";
|
|
case TOK_MOD_ASSIGN: return "%=";
|
|
case TOK_LSHIFT_ASSIGN: return "<<=";
|
|
case TOK_RSHIFT_ASSIGN: return ">>=";
|
|
case TOK_AND_ASSIGN: return "&=";
|
|
case TOK_XOR_ASSIGN: return "^=";
|
|
case TOK_OR_ASSIGN: return "|=";
|
|
case TOK_EQ: return "==";
|
|
case TOK_NEQ: return "!=";
|
|
case TOK_LT: return "<";
|
|
case TOK_LEQ: return "<=";
|
|
case TOK_GT: return ">";
|
|
case TOK_GEQ: return ">=";
|
|
case TOK_NOT: return "!";
|
|
case TOK_BITNOT: return "~";
|
|
case TOK_BITAND: return "&";
|
|
case TOK_BITOR: return "|";
|
|
case TOK_BITXOR: return "^";
|
|
case TOK_AND: return "&&";
|
|
case TOK_OR: return "||";
|
|
case TOK_LSHIFT: return "<<";
|
|
case TOK_RSHIFT: return ">>";
|
|
default: return 0;
|
|
}
|
|
}
|
|
char *token_to_name(Token_Kind kind) {
|
|
switch (kind) {
|
|
case TOK_EOF: return "EOF";
|
|
case TOK_ERROR: return "ERROR";
|
|
case TOK_IDENT: return "IDENT";
|
|
case TOK_KEYWORD: return "KEYWORD";
|
|
case TOK_INT: return "INT";
|
|
case TOK_FLOAT: return "FLOAT";
|
|
case TOK_CHAR: return "CHAR";
|
|
case TOK_STRING: return "STRING";
|
|
case TOK_LPAREN: return "LPAREN";
|
|
case TOK_RPAREN: return "RPAREN";
|
|
case TOK_LBRACKET: return "LBRACKET";
|
|
case TOK_RBRACKET: return "RBRACKET";
|
|
case TOK_LBRACE: return "LBRACE";
|
|
case TOK_RBRACE: return "RBRACE";
|
|
case TOK_COMMA: return "COMMA";
|
|
case TOK_DOT: return "DOT";
|
|
case TOK_ARROW: return "ARROW";
|
|
case TOK_ELLIPSIS: return "ELLIPSIS";
|
|
case TOK_COLON: return "COLON";
|
|
case TOK_SEMICOLON: return "SEMICOLON";
|
|
case TOK_QUESTION: return "QUESTION";
|
|
case TOK_HASH: return "HASH";
|
|
case TOK_HASHHASH: return "HASHHASH";
|
|
case TOK_PLUS: return "PLUS";
|
|
case TOK_MINUS: return "MINUS";
|
|
case TOK_STAR: return "STAR";
|
|
case TOK_SLASH: return "SLASH";
|
|
case TOK_PERCENT: return "PERCENT";
|
|
case TOK_INC: return "INC";
|
|
case TOK_DEC: return "DEC";
|
|
case TOK_ASSIGN: return "ASSIGN";
|
|
case TOK_PLUS_ASSIGN: return "PLUS_ASSIGN";
|
|
case TOK_MINUS_ASSIGN: return "MINUS_ASSIGN";
|
|
case TOK_MUL_ASSIGN: return "MUL_ASSIGN";
|
|
case TOK_DIV_ASSIGN: return "DIV_ASSIGN";
|
|
case TOK_MOD_ASSIGN: return "MOD_ASSIGN";
|
|
case TOK_LSHIFT_ASSIGN: return "LSHIFT_ASSIGN";
|
|
case TOK_RSHIFT_ASSIGN: return "RSHIFT_ASSIGN";
|
|
case TOK_AND_ASSIGN: return "AND_ASSIGN";
|
|
case TOK_XOR_ASSIGN: return "XOR_ASSIGN";
|
|
case TOK_OR_ASSIGN: return "OR_ASSIGN";
|
|
case TOK_EQ: return "EQ";
|
|
case TOK_NEQ: return "NEQ";
|
|
case TOK_LT: return "LT";
|
|
case TOK_LEQ: return "LEQ";
|
|
case TOK_GT: return "GT";
|
|
case TOK_GEQ: return "GEQ";
|
|
case TOK_NOT: return "NOT";
|
|
case TOK_BITNOT: return "BITNOT";
|
|
case TOK_BITAND: return "BITAND";
|
|
case TOK_BITOR: return "BITOR";
|
|
case TOK_BITXOR: return "BITXOR";
|
|
case TOK_AND: return "AND";
|
|
case TOK_OR: return "OR";
|
|
case TOK_LSHIFT: return "LSHIFT";
|
|
case TOK_RSHIFT: return "RSHIFT";
|
|
default: return "<invalid-token-kind>";
|
|
}
|
|
}
|