toolchain: replace ifc interface compiler with xpcg

xpcg is used to generate xpc interfaces
This commit is contained in:
2026-03-10 19:12:14 +00:00
parent 3a06c18e10
commit 26a49162e6
24 changed files with 427 additions and 878 deletions

73
toolchain/xpcg/token.h Normal file
View File

@@ -0,0 +1,73 @@
#ifndef XPCG_TOKEN_H_
#define XPCG_TOKEN_H_
#include "file-span.h"
#include <blue/core/queue.h>
#define TOKEN_TYPE(tok) ((tok) ? (tok)->tok_type : TOK_NONE)
#define TOKEN_IS(tok, type) ((tok) && ((tok)->tok_type & (type)) != 0)
#define TOKEN_IS_SYMBOL(tok, sym) \
((tok) && (tok)->tok_type == TOK_SYMBOL && (tok)->tok_sym == (sym))
enum token_type {
TOK_NONE = 0,
TOK_SYMBOL = 0x0001u,
TOK_KEYWORD = 0x0002u,
TOK_WORD = 0x0004u,
TOK_NAME = 0x0008u,
TOK_INT = 0x0010u,
TOK_STRING = 0x0020u,
__TOK_UBOUND = 0x0040u,
};
enum token_value_type {
TOK_V_NONE = 0,
TOK_V_INT,
TOK_V_STRING,
TOK_V_SYMBOL,
TOK_V_KEYWORD,
};
enum token_symbol {
SYM_NONE = 0,
SYM_COMMA = __TOK_UBOUND,
SYM_HYPHEN,
SYM_SEMICOLON,
SYM_COLON,
SYM_LEFT_BRACKET,
SYM_RIGHT_BRACKET,
SYM_LEFT_BRACE,
SYM_RIGHT_BRACE,
SYM_LEFT_PAREN,
SYM_RIGHT_PAREN,
SYM_HYPHEN_RIGHT_ANGLE,
__SYM_UBOUND,
};
enum token_keyword {
KW_NONE = 0,
KW_INTERFACE = __SYM_UBOUND,
KW_FUNC,
};
struct token {
struct file_span tok_location;
enum token_type tok_type;
enum token_value_type tok_value_type;
b_queue_entry tok_entry;
union {
char *tok_str;
enum token_symbol tok_sym;
enum token_keyword tok_kw;
long long tok_int;
};
};
extern void token_destroy(struct token *tok);
extern const char *token_type_to_string(enum token_type type);
extern const char *token_symbol_to_string(enum token_symbol sym);
extern const char *token_keyword_to_string(enum token_keyword kw);
#endif