1 #ifndef GMQCC_PARSER_HDR 2 #define GMQCC_PARSER_HDR 3 #include "gmqcc.h" 4 #include "lexer.h" 5 //#include "ast.h" 6 7 #include "intrin.h" 8 #include "fold.h" 9 10 struct parser_t; 11 12 #define parser_ctx(p) ((p)->lex->tok.ctx) 13 14 struct parser_t { parser_tparser_t15 parser_t() { } 16 17 lex_file *lex; 18 int tok; 19 20 bool ast_cleaned; 21 22 std::vector<ast_expression *> globals; 23 std::vector<ast_expression *> fields; 24 std::vector<ast_function *> functions; 25 size_t translated; 26 27 /* must be deleted first, they reference immediates and values */ 28 std::vector<ast_value *> accessors; 29 30 ast_value *nil; 31 ast_value *reserved_version; 32 33 size_t crc_globals; 34 size_t crc_fields; 35 36 ast_function *function; 37 ht aliases; 38 39 /* All the labels the function defined... 40 * Should they be in ast_function instead? 41 */ 42 std::vector<ast_label*> labels; 43 std::vector<ast_goto*> gotos; 44 std::vector<const char *> breaks; 45 std::vector<const char *> continues; 46 47 /* A list of hashtables for each scope */ 48 ht *variables; 49 ht htfields; 50 ht htglobals; 51 ht *typedefs; 52 53 /* not to be used directly, we use the hash table */ 54 ast_expression **_locals; 55 size_t *_blocklocals; 56 ast_value **_typedefs; 57 size_t *_blocktypedefs; 58 lex_ctx_t *_block_ctx; 59 60 /* we store the '=' operator info */ 61 const oper_info *assign_op; 62 63 /* magic values */ 64 ast_value *const_vec[3]; 65 66 /* pragma flags */ 67 bool noref; 68 69 /* collected information */ 70 size_t max_param_count; 71 72 fold m_fold; 73 intrin m_intrin; 74 }; 75 76 77 /* parser.c */ 78 char *parser_strdup (const char *str); 79 ast_expression *parser_find_global(parser_t *parser, const char *name); 80 81 #endif 82