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