60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
#pragma once
|
|
typedef struct Type Type;
|
|
typedef struct Expr Expr;
|
|
typedef struct Decl Decl;
|
|
typedef struct Parser_Error Parser_Error;
|
|
|
|
typedef enum Symbol_Kind{
|
|
SK_None,
|
|
SK_Type,
|
|
SK_Const,
|
|
SK_Decl,
|
|
}Symbol_Kind;
|
|
|
|
typedef struct Symbol{
|
|
Symbol_Kind kind;
|
|
Intern_String string;
|
|
Token *token;
|
|
struct{
|
|
Type *type;
|
|
struct{
|
|
Type *type;
|
|
Expr *expr;
|
|
} const_val;
|
|
Decl *decl;
|
|
};
|
|
}Symbol;
|
|
|
|
struct Parser_Error{
|
|
Parser_Error *next;
|
|
String message;
|
|
Token *token;
|
|
};
|
|
|
|
typedef struct Parser{
|
|
Arena main_arena;
|
|
Arena intern_table_arena;
|
|
Arena symbol_table_arena;
|
|
|
|
S64 symbols_inserted;
|
|
Symbol *symbols;
|
|
S64 symbols_count;
|
|
|
|
S64 interns_in_bytes;
|
|
S64 interns_inserted;
|
|
Intern_String *interns;
|
|
S64 interns_count;
|
|
|
|
U8 *first_keyword;
|
|
U8 *last_keyword;
|
|
|
|
Parser_Error *first_error;
|
|
Parser_Error *last_error;
|
|
|
|
Tokens tokens;
|
|
}Parser;
|
|
|
|
function Intern_String intern_string(Parser *p, String string);
|
|
function void type_insert(Parser *p, Type *type, Intern_String string);
|
|
function Token *token_get(Parser *p);
|