1 #ifndef GMQCC_PARSER_HDR
2 #define GMQCC_PARSER_HDR
10 #define parser_ctx(p) ((p).lex->tok.ctx)
23 std::vector<ast_expression *> globals;
24 std::vector<ast_expression *> fields;
25 std::vector<ast_function *> functions;
28 /* must be deleted first, they reference immediates and values */
29 std::vector<ast_value *> accessors;
32 ast_value *reserved_version;
37 ast_function *function;
40 /* All the labels the function defined...
41 * Should they be in ast_function instead?
43 std::vector<ast_label*> labels;
44 std::vector<ast_goto*> gotos;
45 std::vector<const char *> breaks;
46 std::vector<const char *> continues;
48 /* A list of hashtables for each scope */
49 std::vector<ht> variables;
52 std::vector<ht> typedefs;
54 /* not to be used directly, we use the hash table */
55 std::vector<ast_expression*> _locals;
56 std::vector<size_t> _blocklocals;
57 std::vector<std::unique_ptr<ast_value>> _typedefs;
58 std::vector<size_t> _blocktypedefs;
59 std::vector<lex_ctx_t> _block_ctx;
61 /* we store the '=' operator info */
62 const oper_info *assign_op;
65 ast_value *const_vec[3];
70 /* collected information */
71 size_t max_param_count;
78 inline char *parser_strdup(const char *str)
81 /* actually dup empty strings */
82 auto *out = reinterpret_cast<char*>(mem_a(1));
86 return util_strdup(str);
88 ast_expression *parser_find_global(parser_t &parser, const char *name);
89 parser_t *parser_create();
90 bool parser_compile_file(parser_t &parser, const char *);
91 bool parser_compile_string(parser_t &parser, const char *, const char *, size_t);
92 bool parser_finish(parser_t &parser, const char *);