blob: 961c6ef8ab3e66cc4eeecc07531fa458c491554d [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Mark Sleee9ce01c2007-05-16 02:29:53 +000019
Mark Slee31985722006-05-24 21:45:31 +000020#ifndef T_GLOBALS_H
21#define T_GLOBALS_H
22
Mark Sleef0712dc2006-10-25 19:03:57 +000023#include <set>
24#include <queue>
25#include <stack>
26#include <vector>
27#include <string>
28
29/**
30 * This module contains all the global variables (slap on the wrist) that are
31 * shared throughout the program. The reason for this is to facilitate simple
32 * interaction between the parser and the rest of the program. Before calling
33 * yyparse(), the main.cc program will make necessary adjustments to these
34 * global variables such that the parser does the right thing and puts entries
35 * into the right containers, etc.
36 *
Mark Sleef0712dc2006-10-25 19:03:57 +000037 */
38
39/**
40 * Hooray for forward declaration of types!
41 */
42
Mark Slee31985722006-05-24 21:45:31 +000043class t_program;
Mark Sleef0712dc2006-10-25 19:03:57 +000044class t_scope;
45class t_type;
46
47/**
48 * Parsing mode, two passes up in this gin rummy!
49 */
50
Konrad Grochowski16a23a62014-11-13 15:33:38 +010051enum PARSE_MODE { INCLUDES = 1, PROGRAM = 2 };
Mark Slee31985722006-05-24 21:45:31 +000052
Mark Sleef5377b32006-10-10 01:42:59 +000053/**
Bryan Duxburya145b4d2009-04-03 17:29:25 +000054 * Strictness level
55 */
56extern int g_strict;
57
58/**
Mark Sleef5377b32006-10-10 01:42:59 +000059 * The master program parse tree. This is accessed from within the parser code
60 * to build up the program elements.
61 */
Mark Slee31985722006-05-24 21:45:31 +000062extern t_program* g_program;
63
Mark Sleef5377b32006-10-10 01:42:59 +000064/**
Mark Sleef0712dc2006-10-25 19:03:57 +000065 * 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
Bryan Duxburyc7206a42011-08-17 23:17:04 +000099/**
Jens Geyere8379b52014-01-25 00:59:45 +0100100 * Status of program level doctext candidate
101 */
102enum PROGDOCTEXT_STATUS {
103 INVALID = 0,
Konrad Grochowski16a23a62014-11-13 15:33:38 +0100104 STILL_CANDIDATE = 1, // the text may or may not be the program doctext
105 ALREADY_PROCESSED = 2, // doctext has been used and is no longer available
106 ABSOLUTELY_SURE = 3, // this is the program doctext
107 NO_PROGRAM_DOCTEXT = 4 // there is no program doctext
Jens Geyere8379b52014-01-25 00:59:45 +0100108};
109
Jens Geyere8379b52014-01-25 00:59:45 +0100110/**
Konrad Grochowski3b5dacb2014-11-24 10:55:31 +0100111 * The program level doctext. Stored separately to make parsing easier.
Jens Geyere8379b52014-01-25 00:59:45 +0100112 */
113extern char* g_program_doctext_candidate;
Konrad Grochowski16a23a62014-11-13 15:33:38 +0100114extern int g_program_doctext_lineno;
115extern PROGDOCTEXT_STATUS g_program_doctext_status;
Jens Geyere8379b52014-01-25 00:59:45 +0100116
117/**
Bryan Duxburyc7206a42011-08-17 23:17:04 +0000118 * Whether or not negative field keys are accepted.
119 *
120 * When a field does not have a user-specified key, thrift automatically
121 * assigns a negative value. However, this is fragile since changes to the
122 * file may unintentionally change the key numbering, resulting in a new
123 * protocol that is not backwards compatible.
124 *
125 * When g_allow_neg_field_keys is enabled, users can explicitly specify
126 * negative keys. This way they can write a .thrift file with explicitly
127 * specified keys that is still backwards compatible with older .thrift files
128 * that did not specify key values.
129 */
130extern int g_allow_neg_field_keys;
131
Roger Meier887ff752011-08-19 11:25:39 +0000132/**
133 * Whether or not 64-bit constants will generate a warning.
134 *
135 * Some languages don't support 64-bit constants, but many do, so we can
136 * suppress this warning for projects that don't use any non-64-bit-safe
137 * languages.
138 */
139extern int g_allow_64bit_consts;
140
Mark Slee31985722006-05-24 21:45:31 +0000141#endif