blob: 8b3ae193275bfa5422961e8a25beb412a4fa8403 [file] [log] [blame]
Mark Sleee9ce01c2007-05-16 02:29:53 +00001// 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 Slee31985722006-05-24 21:45:31 +00007#ifndef T_GLOBALS_H
8#define T_GLOBALS_H
9
Mark Sleef0712dc2006-10-25 19:03:57 +000010#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 Slee31985722006-05-24 21:45:31 +000031class t_program;
Mark Sleef0712dc2006-10-25 19:03:57 +000032class t_scope;
33class t_type;
34
35/**
36 * Parsing mode, two passes up in this gin rummy!
37 */
38
39enum PARSE_MODE {
40 INCLUDES = 1,
41 PROGRAM = 2
42};
Mark Slee31985722006-05-24 21:45:31 +000043
Mark Sleef5377b32006-10-10 01:42:59 +000044/**
45 * The master program parse tree. This is accessed from within the parser code
46 * to build up the program elements.
47 */
Mark Slee31985722006-05-24 21:45:31 +000048extern t_program* g_program;
49
Mark Sleef5377b32006-10-10 01:42:59 +000050/**
Mark Sleef0712dc2006-10-25 19:03:57 +000051 * Global types for the parser to be able to reference
Mark Sleef5377b32006-10-10 01:42:59 +000052 */
Mark Sleef0712dc2006-10-25 19:03:57 +000053
54extern t_type* g_type_void;
55extern t_type* g_type_string;
Mark Slee8d725a22007-04-13 01:57:12 +000056extern t_type* g_type_binary;
Mark Sleeb6200d82007-01-19 19:14:36 +000057extern t_type* g_type_slist;
Mark Sleef0712dc2006-10-25 19:03:57 +000058extern t_type* g_type_bool;
59extern t_type* g_type_byte;
60extern t_type* g_type_i16;
61extern t_type* g_type_i32;
62extern t_type* g_type_i64;
63extern t_type* g_type_double;
64
65/**
66 * The scope that we are currently parsing into
67 */
68extern t_scope* g_scope;
69
70/**
71 * The parent scope to also load symbols into
72 */
73extern t_scope* g_parent_scope;
74
75/**
76 * The prefix for the parent scope entries
77 */
78extern std::string g_parent_prefix;
79
80/**
81 * The parsing pass that we are on. We do different things on each pass.
82 */
83extern PARSE_MODE g_parse_mode;
Mark Slee31985722006-05-24 21:45:31 +000084
Mark Sleef5377b32006-10-10 01:42:59 +000085/**
86 * Global time string, used in formatting error messages etc.
87 */
Mark Slee31985722006-05-24 21:45:31 +000088extern char* g_time_str;
89
90#endif