blob: 51502c7529eecbd39900810f7d9e88d1e22f344c [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;
50extern t_type* g_type_bool;
51extern t_type* g_type_byte;
52extern t_type* g_type_i16;
53extern t_type* g_type_i32;
54extern t_type* g_type_i64;
55extern t_type* g_type_double;
56
57/**
58 * The scope that we are currently parsing into
59 */
60extern t_scope* g_scope;
61
62/**
63 * The parent scope to also load symbols into
64 */
65extern t_scope* g_parent_scope;
66
67/**
68 * The prefix for the parent scope entries
69 */
70extern std::string g_parent_prefix;
71
72/**
73 * The parsing pass that we are on. We do different things on each pass.
74 */
75extern PARSE_MODE g_parse_mode;
Mark Slee31985722006-05-24 21:45:31 +000076
Mark Sleef5377b32006-10-10 01:42:59 +000077/**
78 * Global time string, used in formatting error messages etc.
79 */
Mark Slee31985722006-05-24 21:45:31 +000080extern char* g_time_str;
81
82#endif