blob: afc41da2942e64579fa6091db4e9a06b557bbe46 [file] [log] [blame]
Mark Slee31985722006-05-24 21:45:31 +00001#ifndef T_GLOBALS_H
2#define T_GLOBALS_H
3
Mark Sleef0712dc2006-10-25 19:03:57 +00004#include <set>
5#include <queue>
6#include <stack>
7#include <vector>
8#include <string>
9
10/**
11 * This module contains all the global variables (slap on the wrist) that are
12 * shared throughout the program. The reason for this is to facilitate simple
13 * interaction between the parser and the rest of the program. Before calling
14 * yyparse(), the main.cc program will make necessary adjustments to these
15 * global variables such that the parser does the right thing and puts entries
16 * into the right containers, etc.
17 *
18 * @author Mark Slee <mcslee@facebook.com>
19 */
20
21/**
22 * Hooray for forward declaration of types!
23 */
24
Mark Slee31985722006-05-24 21:45:31 +000025class t_program;
Mark Sleef0712dc2006-10-25 19:03:57 +000026class t_scope;
27class t_type;
28
29/**
30 * Parsing mode, two passes up in this gin rummy!
31 */
32
33enum PARSE_MODE {
34 INCLUDES = 1,
35 PROGRAM = 2
36};
Mark Slee31985722006-05-24 21:45:31 +000037
Mark Sleef5377b32006-10-10 01:42:59 +000038/**
39 * The master program parse tree. This is accessed from within the parser code
40 * to build up the program elements.
41 */
Mark Slee31985722006-05-24 21:45:31 +000042extern t_program* g_program;
43
Mark Sleef5377b32006-10-10 01:42:59 +000044/**
Mark Sleef0712dc2006-10-25 19:03:57 +000045 * Global types for the parser to be able to reference
Mark Sleef5377b32006-10-10 01:42:59 +000046 */
Mark Sleef0712dc2006-10-25 19:03:57 +000047
48extern t_type* g_type_void;
49extern t_type* g_type_string;
Mark Slee8d725a22007-04-13 01:57:12 +000050extern t_type* g_type_binary;
Mark Sleeb6200d82007-01-19 19:14:36 +000051extern t_type* g_type_slist;
Mark Sleef0712dc2006-10-25 19:03:57 +000052extern t_type* g_type_bool;
53extern t_type* g_type_byte;
54extern t_type* g_type_i16;
55extern t_type* g_type_i32;
56extern t_type* g_type_i64;
57extern t_type* g_type_double;
58
59/**
60 * The scope that we are currently parsing into
61 */
62extern t_scope* g_scope;
63
64/**
65 * The parent scope to also load symbols into
66 */
67extern t_scope* g_parent_scope;
68
69/**
70 * The prefix for the parent scope entries
71 */
72extern std::string g_parent_prefix;
73
74/**
75 * The parsing pass that we are on. We do different things on each pass.
76 */
77extern PARSE_MODE g_parse_mode;
Mark Slee31985722006-05-24 21:45:31 +000078
Mark Sleef5377b32006-10-10 01:42:59 +000079/**
80 * Global time string, used in formatting error messages etc.
81 */
Mark Slee31985722006-05-24 21:45:31 +000082extern char* g_time_str;
83
84#endif