Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 1 | #ifndef T_GLOBALS_H |
| 2 | #define T_GLOBALS_H |
| 3 | |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame^] | 4 | #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 Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 25 | class t_program; |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame^] | 26 | class t_scope; |
| 27 | class t_type; |
| 28 | |
| 29 | /** |
| 30 | * Parsing mode, two passes up in this gin rummy! |
| 31 | */ |
| 32 | |
| 33 | enum PARSE_MODE { |
| 34 | INCLUDES = 1, |
| 35 | PROGRAM = 2 |
| 36 | }; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 37 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 38 | /** |
| 39 | * The master program parse tree. This is accessed from within the parser code |
| 40 | * to build up the program elements. |
| 41 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 42 | extern t_program* g_program; |
| 43 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 44 | /** |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame^] | 45 | * Global types for the parser to be able to reference |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 46 | */ |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame^] | 47 | |
| 48 | extern t_type* g_type_void; |
| 49 | extern t_type* g_type_string; |
| 50 | extern t_type* g_type_bool; |
| 51 | extern t_type* g_type_byte; |
| 52 | extern t_type* g_type_i16; |
| 53 | extern t_type* g_type_i32; |
| 54 | extern t_type* g_type_i64; |
| 55 | extern t_type* g_type_double; |
| 56 | |
| 57 | /** |
| 58 | * The scope that we are currently parsing into |
| 59 | */ |
| 60 | extern t_scope* g_scope; |
| 61 | |
| 62 | /** |
| 63 | * The parent scope to also load symbols into |
| 64 | */ |
| 65 | extern t_scope* g_parent_scope; |
| 66 | |
| 67 | /** |
| 68 | * The prefix for the parent scope entries |
| 69 | */ |
| 70 | extern std::string g_parent_prefix; |
| 71 | |
| 72 | /** |
| 73 | * The parsing pass that we are on. We do different things on each pass. |
| 74 | */ |
| 75 | extern PARSE_MODE g_parse_mode; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 76 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 77 | /** |
| 78 | * Global time string, used in formatting error messages etc. |
| 79 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 80 | extern char* g_time_str; |
| 81 | |
| 82 | #endif |