toolchain: replace ifc interface compiler with xpcg
xpcg is used to generate xpc interfaces
This commit is contained in:
64
toolchain/xpcg/token.c
Normal file
64
toolchain/xpcg/token.c
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "token.h"
|
||||
|
||||
void token_destroy(struct token *tok)
|
||||
{
|
||||
switch (tok->tok_value_type) {
|
||||
case TOK_V_STRING:
|
||||
if (tok->tok_str) {
|
||||
free(tok->tok_str);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
free(tok);
|
||||
}
|
||||
|
||||
#define ENUM_STR(x) \
|
||||
case x: \
|
||||
return #x
|
||||
|
||||
const char *token_type_to_string(enum token_type type)
|
||||
{
|
||||
switch (type) {
|
||||
ENUM_STR(TOK_NONE);
|
||||
ENUM_STR(TOK_INT);
|
||||
ENUM_STR(TOK_SYMBOL);
|
||||
ENUM_STR(TOK_WORD);
|
||||
ENUM_STR(TOK_NAME);
|
||||
ENUM_STR(TOK_STRING);
|
||||
ENUM_STR(TOK_KEYWORD);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
const char *token_symbol_to_string(enum token_symbol sym)
|
||||
{
|
||||
switch (sym) {
|
||||
ENUM_STR(SYM_NONE);
|
||||
ENUM_STR(SYM_COMMA);
|
||||
ENUM_STR(SYM_SEMICOLON);
|
||||
ENUM_STR(SYM_COLON);
|
||||
ENUM_STR(SYM_HYPHEN);
|
||||
ENUM_STR(SYM_LEFT_BRACE);
|
||||
ENUM_STR(SYM_RIGHT_BRACE);
|
||||
ENUM_STR(SYM_LEFT_PAREN);
|
||||
ENUM_STR(SYM_RIGHT_PAREN);
|
||||
ENUM_STR(SYM_HYPHEN_RIGHT_ANGLE);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
const char *token_keyword_to_string(enum token_keyword kw)
|
||||
{
|
||||
switch (kw) {
|
||||
ENUM_STR(KW_NONE);
|
||||
ENUM_STR(KW_INTERFACE);
|
||||
ENUM_STR(KW_FUNC);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user