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 | * |
| 24 | * @author Mark Slee <mcslee@facebook.com> |
| 25 | */ |
| 26 | |
| 27 | /** |
| 28 | * Hooray for forward declaration of types! |
| 29 | */ |
| 30 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 31 | class t_program; |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 32 | class t_scope; |
| 33 | class t_type; |
| 34 | |
| 35 | /** |
| 36 | * Parsing mode, two passes up in this gin rummy! |
| 37 | */ |
| 38 | |
| 39 | enum PARSE_MODE { |
| 40 | INCLUDES = 1, |
| 41 | PROGRAM = 2 |
| 42 | }; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 43 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 44 | /** |
| 45 | * The master program parse tree. This is accessed from within the parser code |
| 46 | * to build up the program elements. |
| 47 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 48 | extern t_program* g_program; |
| 49 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 50 | /** |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 51 | * Global types for the parser to be able to reference |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 52 | */ |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 53 | |
| 54 | extern t_type* g_type_void; |
| 55 | extern t_type* g_type_string; |
Mark Slee | 8d725a2 | 2007-04-13 01:57:12 +0000 | [diff] [blame] | 56 | extern t_type* g_type_binary; |
Mark Slee | b6200d8 | 2007-01-19 19:14:36 +0000 | [diff] [blame] | 57 | extern t_type* g_type_slist; |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 58 | extern t_type* g_type_bool; |
| 59 | extern t_type* g_type_byte; |
| 60 | extern t_type* g_type_i16; |
| 61 | extern t_type* g_type_i32; |
| 62 | extern t_type* g_type_i64; |
| 63 | extern t_type* g_type_double; |
| 64 | |
| 65 | /** |
| 66 | * The scope that we are currently parsing into |
| 67 | */ |
| 68 | extern t_scope* g_scope; |
| 69 | |
| 70 | /** |
| 71 | * The parent scope to also load symbols into |
| 72 | */ |
| 73 | extern t_scope* g_parent_scope; |
| 74 | |
| 75 | /** |
| 76 | * The prefix for the parent scope entries |
| 77 | */ |
| 78 | extern std::string g_parent_prefix; |
| 79 | |
| 80 | /** |
| 81 | * The parsing pass that we are on. We do different things on each pass. |
| 82 | */ |
| 83 | extern PARSE_MODE g_parse_mode; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 84 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 85 | /** |
| 86 | * Global time string, used in formatting error messages etc. |
| 87 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 88 | extern char* g_time_str; |
| 89 | |
David Reiss | cbd4bac | 2007-08-14 17:12:33 +0000 | [diff] [blame^] | 90 | /** |
| 91 | * The last parsed doctext comment. |
| 92 | */ |
| 93 | extern char* g_doctext; |
| 94 | |
| 95 | /** |
| 96 | * The location of the last parsed doctext comment. |
| 97 | */ |
| 98 | extern int g_doctext_lineno; |
| 99 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 100 | #endif |