Mark Slee | e9ce01c | 2007-05-16 02:29:53 +0000 | [diff] [blame] | 1 | // Copyright (c) 2006- Facebook |
| 2 | // Distributed under the Thrift Software License |
| 3 | // |
| 4 | // See accompanying file LICENSE or visit the Thrift site at: |
| 5 | // http://developers.facebook.com/thrift/ |
| 6 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 7 | #ifndef T_GLOBALS_H |
| 8 | #define T_GLOBALS_H |
| 9 | |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 10 | #include <set> |
| 11 | #include <queue> |
| 12 | #include <stack> |
| 13 | #include <vector> |
| 14 | #include <string> |
| 15 | |
| 16 | /** |
| 17 | * This module contains all the global variables (slap on the wrist) that are |
| 18 | * shared throughout the program. The reason for this is to facilitate simple |
| 19 | * interaction between the parser and the rest of the program. Before calling |
| 20 | * yyparse(), the main.cc program will make necessary adjustments to these |
| 21 | * global variables such that the parser does the right thing and puts entries |
| 22 | * into the right containers, etc. |
| 23 | * |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | /** |
| 27 | * Hooray for forward declaration of types! |
| 28 | */ |
| 29 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 30 | class t_program; |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 31 | class t_scope; |
| 32 | class t_type; |
| 33 | |
| 34 | /** |
| 35 | * Parsing mode, two passes up in this gin rummy! |
| 36 | */ |
| 37 | |
| 38 | enum PARSE_MODE { |
| 39 | INCLUDES = 1, |
| 40 | PROGRAM = 2 |
| 41 | }; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 42 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 43 | /** |
| 44 | * The master program parse tree. This is accessed from within the parser code |
| 45 | * to build up the program elements. |
| 46 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 47 | extern t_program* g_program; |
| 48 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 49 | /** |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 50 | * Global types for the parser to be able to reference |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 51 | */ |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 52 | |
| 53 | extern t_type* g_type_void; |
| 54 | extern t_type* g_type_string; |
Mark Slee | 8d725a2 | 2007-04-13 01:57:12 +0000 | [diff] [blame] | 55 | extern t_type* g_type_binary; |
Mark Slee | b6200d8 | 2007-01-19 19:14:36 +0000 | [diff] [blame] | 56 | extern t_type* g_type_slist; |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 57 | extern t_type* g_type_bool; |
| 58 | extern t_type* g_type_byte; |
| 59 | extern t_type* g_type_i16; |
| 60 | extern t_type* g_type_i32; |
| 61 | extern t_type* g_type_i64; |
| 62 | extern t_type* g_type_double; |
| 63 | |
| 64 | /** |
| 65 | * The scope that we are currently parsing into |
| 66 | */ |
| 67 | extern t_scope* g_scope; |
| 68 | |
| 69 | /** |
| 70 | * The parent scope to also load symbols into |
| 71 | */ |
| 72 | extern t_scope* g_parent_scope; |
| 73 | |
| 74 | /** |
| 75 | * The prefix for the parent scope entries |
| 76 | */ |
| 77 | extern std::string g_parent_prefix; |
| 78 | |
| 79 | /** |
| 80 | * The parsing pass that we are on. We do different things on each pass. |
| 81 | */ |
| 82 | extern PARSE_MODE g_parse_mode; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 83 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 84 | /** |
| 85 | * Global time string, used in formatting error messages etc. |
| 86 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 87 | extern char* g_time_str; |
| 88 | |
David Reiss | cbd4bac | 2007-08-14 17:12:33 +0000 | [diff] [blame] | 89 | /** |
| 90 | * The last parsed doctext comment. |
| 91 | */ |
| 92 | extern char* g_doctext; |
| 93 | |
| 94 | /** |
| 95 | * The location of the last parsed doctext comment. |
| 96 | */ |
| 97 | extern int g_doctext_lineno; |
| 98 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 99 | #endif |