minic: registry enumeration
This commit is contained in:
+29
-12
@@ -16,18 +16,19 @@
|
||||
// ██║ ╚██████╔╝██║ ██╗███████╗██║ ╚████║
|
||||
// ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝
|
||||
|
||||
#define MINIC_TOK_LIST \
|
||||
X(TOK_INT, "'int'") \
|
||||
X(TOK_FLOAT, "'float'") \
|
||||
X(TOK_CHAR, "'char'") \
|
||||
X(TOK_DOUBLE, "'double'") X(TOK_BOOL, "'bool'") X(TOK_RETURN, "'return'") X(TOK_IF, "'if'") X(TOK_ELSE, "'else'") X(TOK_WHILE, "'while'") \
|
||||
X(TOK_FOR, "'for'") X(TOK_BREAK, "'break'") X(TOK_CONTINUE, "'continue'") X(TOK_STRUCT, "'struct'") X(TOK_TYPEDEF, "'typedef'") X(TOK_ENUM, "'enum'") \
|
||||
X(TOK_VOID, "'void'") X(TOK_IDENT, "identifier") X(TOK_NUMBER, "number") X(TOK_CHAR_LIT, "char literal") X(TOK_STR_LIT, "string literal") \
|
||||
X(TOK_LPAREN, "'('") X(TOK_RPAREN, "')'") X(TOK_LBRACE, "'{'") X(TOK_RBRACE, "'}'") X(TOK_LBRACKET, "'['") X(TOK_RBRACKET, "']'") \
|
||||
X(TOK_SEMICOLON, "';'") X(TOK_COMMA, "','") X(TOK_ASSIGN, "'='") X(TOK_PLUS_ASSIGN, "'+='") X(TOK_MINUS_ASSIGN, "'-='") \
|
||||
X(TOK_MUL_ASSIGN, "'*='") X(TOK_DIV_ASSIGN, "'/='") X(TOK_EQ, "'=='") X(TOK_NEQ, "'!='") X(TOK_LT, "'<'") X(TOK_GT, "'>'") \
|
||||
X(TOK_LE, "'<='") X(TOK_GE, "'>='") X(TOK_AND, "'&&'") X(TOK_OR, "'||'") X(TOK_NOT, "'!'") X(TOK_AMP, "'&'") X(TOK_PLUS, "'+'") \
|
||||
X(TOK_MINUS, "'-'") X(TOK_INC, "'++'") X(TOK_DEC, "'--'") X(TOK_STAR, "'*'") X(TOK_SLASH, "'/'") X(TOK_DOT, "'.'") \
|
||||
#define MINIC_TOK_LIST \
|
||||
X(TOK_INT, "'int'") \
|
||||
X(TOK_FLOAT, "'float'") \
|
||||
X(TOK_CHAR, "'char'") \
|
||||
X(TOK_DOUBLE, "'double'") \
|
||||
X(TOK_BOOL, "'bool'") X(TOK_RETURN, "'return'") X(TOK_IF, "'if'") X(TOK_ELSE, "'else'") X(TOK_WHILE, "'while'") X(TOK_FOR, "'for'") \
|
||||
X(TOK_BREAK, "'break'") X(TOK_CONTINUE, "'continue'") X(TOK_STRUCT, "'struct'") X(TOK_TYPEDEF, "'typedef'") X(TOK_ENUM, "'enum'") \
|
||||
X(TOK_VOID, "'void'") X(TOK_IDENT, "identifier") X(TOK_NUMBER, "number") X(TOK_CHAR_LIT, "char literal") X(TOK_STR_LIT, "string literal") \
|
||||
X(TOK_LPAREN, "'('") X(TOK_RPAREN, "')'") X(TOK_LBRACE, "'{'") X(TOK_RBRACE, "'}'") X(TOK_LBRACKET, "'['") X(TOK_RBRACKET, "']'") \
|
||||
X(TOK_SEMICOLON, "';'") X(TOK_COMMA, "','") X(TOK_ASSIGN, "'='") X(TOK_PLUS_ASSIGN, "'+='") X(TOK_MINUS_ASSIGN, "'-='") \
|
||||
X(TOK_MUL_ASSIGN, "'*='") X(TOK_DIV_ASSIGN, "'/='") X(TOK_EQ, "'=='") X(TOK_NEQ, "'!='") X(TOK_LT, "'<'") X(TOK_GT, "'>'") \
|
||||
X(TOK_LE, "'<='") X(TOK_GE, "'>='") X(TOK_AND, "'&&'") X(TOK_OR, "'||'") X(TOK_NOT, "'!'") X(TOK_AMP, "'&'") X(TOK_PLUS, "'+'") \
|
||||
X(TOK_MINUS, "'-'") X(TOK_INC, "'++'") X(TOK_DEC, "'--'") X(TOK_STAR, "'*'") X(TOK_SLASH, "'/'") X(TOK_DOT, "'.'") \
|
||||
X(TOK_ARROW, "'->'") X(TOK_EOF, "end of file")
|
||||
|
||||
typedef enum {
|
||||
@@ -2136,6 +2137,22 @@ minic_ext_func_t *minic_ext_func_get(const char *name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int minic_ext_func_count_get(void) {
|
||||
return minic_ext_func_count;
|
||||
}
|
||||
|
||||
const char *minic_ext_func_name_at(int i) {
|
||||
return minic_ext_funcs[i].name;
|
||||
}
|
||||
|
||||
int minic_global_count_get(void) {
|
||||
return minic_global_count;
|
||||
}
|
||||
|
||||
const char *minic_global_name_at(int i) {
|
||||
return minic_globals[i].name;
|
||||
}
|
||||
|
||||
// ██████╗ ██╗███████╗██████╗ █████╗ ████████╗ ██████╗██╗ ██╗
|
||||
// ██╔══██╗██║██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██║ ██║
|
||||
// ██║ ██║██║███████╗██████╔╝███████║ ██║ ██║ ███████║
|
||||
|
||||
@@ -91,6 +91,12 @@ void minic_int_typedef_add(const char *name);
|
||||
void minic_register_global(const char *name, const void *ptr, minic_type_t type);
|
||||
void minic_register_builtins(void);
|
||||
|
||||
// Registry enumeration (used for editor autocomplete)
|
||||
int minic_ext_func_count_get(void);
|
||||
const char *minic_ext_func_name_at(int i);
|
||||
int minic_global_count_get(void);
|
||||
const char *minic_global_name_at(int i);
|
||||
|
||||
// Registry lookups (used by the interpreter)
|
||||
minic_ext_func_t *minic_ext_func_get(const char *name);
|
||||
minic_val_t minic_dispatch(minic_ext_func_t *ef, minic_val_t *args, int argc);
|
||||
|
||||
Reference in New Issue
Block a user