| 30 |
ashish |
1 |
/*
|
|
|
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 |
*/
|
|
|
19 |
|
|
|
20 |
#ifndef T_GLOBALS_H
|
|
|
21 |
#define T_GLOBALS_H
|
|
|
22 |
|
|
|
23 |
#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 |
*
|
|
|
37 |
*/
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Hooray for forward declaration of types!
|
|
|
41 |
*/
|
|
|
42 |
|
|
|
43 |
class t_program;
|
|
|
44 |
class t_scope;
|
|
|
45 |
class t_type;
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* Parsing mode, two passes up in this gin rummy!
|
|
|
49 |
*/
|
|
|
50 |
|
|
|
51 |
enum PARSE_MODE {
|
|
|
52 |
INCLUDES = 1,
|
|
|
53 |
PROGRAM = 2
|
|
|
54 |
};
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Strictness level
|
|
|
58 |
*/
|
|
|
59 |
extern int g_strict;
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* The master program parse tree. This is accessed from within the parser code
|
|
|
63 |
* to build up the program elements.
|
|
|
64 |
*/
|
|
|
65 |
extern t_program* g_program;
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Global types for the parser to be able to reference
|
|
|
69 |
*/
|
|
|
70 |
|
|
|
71 |
extern t_type* g_type_void;
|
|
|
72 |
extern t_type* g_type_string;
|
|
|
73 |
extern t_type* g_type_binary;
|
|
|
74 |
extern t_type* g_type_slist;
|
|
|
75 |
extern t_type* g_type_bool;
|
|
|
76 |
extern t_type* g_type_byte;
|
|
|
77 |
extern t_type* g_type_i16;
|
|
|
78 |
extern t_type* g_type_i32;
|
|
|
79 |
extern t_type* g_type_i64;
|
|
|
80 |
extern t_type* g_type_double;
|
|
|
81 |
|
|
|
82 |
/**
|
|
|
83 |
* The scope that we are currently parsing into
|
|
|
84 |
*/
|
|
|
85 |
extern t_scope* g_scope;
|
|
|
86 |
|
|
|
87 |
/**
|
|
|
88 |
* The parent scope to also load symbols into
|
|
|
89 |
*/
|
|
|
90 |
extern t_scope* g_parent_scope;
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* The prefix for the parent scope entries
|
|
|
94 |
*/
|
|
|
95 |
extern std::string g_parent_prefix;
|
|
|
96 |
|
|
|
97 |
/**
|
|
|
98 |
* The parsing pass that we are on. We do different things on each pass.
|
|
|
99 |
*/
|
|
|
100 |
extern PARSE_MODE g_parse_mode;
|
|
|
101 |
|
|
|
102 |
/**
|
|
|
103 |
* Global time string, used in formatting error messages etc.
|
|
|
104 |
*/
|
|
|
105 |
extern char* g_time_str;
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* The last parsed doctext comment.
|
|
|
109 |
*/
|
|
|
110 |
extern char* g_doctext;
|
|
|
111 |
|
|
|
112 |
/**
|
|
|
113 |
* The location of the last parsed doctext comment.
|
|
|
114 |
*/
|
|
|
115 |
extern int g_doctext_lineno;
|
|
|
116 |
|
|
|
117 |
#endif
|