blob: 0e89f51f7552e2cddff10985a2fdd5816a4b927d [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 *
Mark Sleef0712dc2006-10-25 19:03:57 +000024 */
25
26/**
27 * Hooray for forward declaration of types!
28 */
29
Mark Slee31985722006-05-24 21:45:31 +000030class t_program;
Mark Sleef0712dc2006-10-25 19:03:57 +000031class t_scope;
32class t_type;
33
34/**
35 * Parsing mode, two passes up in this gin rummy!
36 */
37
38enum PARSE_MODE {
39 INCLUDES = 1,
40 PROGRAM = 2
41};
Mark Slee31985722006-05-24 21:45:31 +000042
Mark Sleef5377b32006-10-10 01:42:59 +000043/**
44 * The master program parse tree. This is accessed from within the parser code
45 * to build up the program elements.
46 */
Mark Slee31985722006-05-24 21:45:31 +000047extern t_program* g_program;
48
Mark Sleef5377b32006-10-10 01:42:59 +000049/**
Mark Sleef0712dc2006-10-25 19:03:57 +000050 * Global types for the parser to be able to reference
Mark Sleef5377b32006-10-10 01:42:59 +000051 */
Mark Sleef0712dc2006-10-25 19:03:57 +000052
53extern t_type* g_type_void;
54extern t_type* g_type_string;
Mark Slee8d725a22007-04-13 01:57:12 +000055extern t_type* g_type_binary;
Mark Sleeb6200d82007-01-19 19:14:36 +000056extern t_type* g_type_slist;
Mark Sleef0712dc2006-10-25 19:03:57 +000057extern t_type* g_type_bool;
58extern t_type* g_type_byte;
59extern t_type* g_type_i16;
60extern t_type* g_type_i32;
61extern t_type* g_type_i64;
62extern t_type* g_type_double;
63
64/**
65 * The scope that we are currently parsing into
66 */
67extern t_scope* g_scope;
68
69/**
70 * The parent scope to also load symbols into
71 */
72extern t_scope* g_parent_scope;
73
74/**
75 * The prefix for the parent scope entries
76 */
77extern std::string g_parent_prefix;
78
79/**
80 * The parsing pass that we are on. We do different things on each pass.
81 */
82extern PARSE_MODE g_parse_mode;
Mark Slee31985722006-05-24 21:45:31 +000083
Mark Sleef5377b32006-10-10 01:42:59 +000084/**
85 * Global time string, used in formatting error messages etc.
86 */
Mark Slee31985722006-05-24 21:45:31 +000087extern char* g_time_str;
88
David Reisscbd4bac2007-08-14 17:12:33 +000089/**
90 * The last parsed doctext comment.
91 */
92extern char* g_doctext;
93
94/**
95 * The location of the last parsed doctext comment.
96 */
97extern int g_doctext_lineno;
98
Mark Slee31985722006-05-24 21:45:31 +000099#endif