rasdaman complete source
symbtbl.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 #ifndef __SYMBTABLE_H
24 #define __SYMBTABLE_H
25 
26 #include "parse.hh"
27 
28 #include <string.h>
29 
30 class YSymbol;
31 
32 //@ManMemo: Module: {\bf rasdl}
33 
42 {
43 
44  friend class YSymbol;
45 
46 public:
48  YSymbolTable();
49 
51  const YSymbol *get_symbol(const char*name)const;
53  bool scoped_symbol(YSymbol**result,const char*name,const YWhere&where);
55  const YSymbol *get_defining_symbol ()const;
56 
58  bool search_scope (const char*,YSymbol*&)const;
60  bool search_scopes (const char*,YSymbol*&)const;
62  bool search_scopes_above (const YSymbol*,YSymbol*&)const;
64  bool search_my_scope (const char*,const YSymbol*,YSymbol*&)const;
66  bool search_global_scope (const char*,YSymbol*&)const;
67 
69  void insert_symbol (YSymbol*)const;
70 
72  void push_scope(YSymbol*);
73 
75  const YSymbol *pop_scope();
76 
78  struct Scope
79  {
80  void output(FILE*out) const;
81  void insertData() const;
82 
83  struct Scope *up;
84  struct Scope *next,*son;
85 
87  YSymbol *last_symbol; // last symbol defined in list {to assure correct order of symbols}
88 
89  const YSymbol *owner; // which symbol is the owner of this scope
90  };
91 
94 
97 
99  inline bool search_this_scope (const char*,const Scope*,YSymbol*&)const;
100 
101 };
102 
103 
104 
105 //@ManMemo: Module: {\bf rasdl}
106 
110 struct YLiteral
111 {
114 
116  union
117  {
119  double Real;
121  long Integer;
123  const char *String;
125  char Character;
127  bool Boolean;
128  };
129 };
130 
131 
132 
133 //@ManMemo: Module: {\bf rasdl}
134 
138 struct YConstant
139 {
144 };
145 
146 
147 
148 //@ManMemo: Module: {\bf rasdl}
149 
157 class YSymbol
158 {
159  friend class YSymbolTable;
160 
161 public:
163  YSymbol();
165  YSymbol(const char*);
166 
168  const char *get_name()const
169  {
170  return(name);
171  };
172 
174  YWhere where;
177 
178 private:
180  const char *name;
181 
182 public:
189 
196  } type;
198  union
199  {
206 
209  };
210 };
211 #endif
212 
Definition: parse.hh:586
YWhere where
defined where
Definition: symbtbl.hh:171
Parse_type * Type
Definition: symbtbl.hh:201
struct Scope * son
Definition: symbtbl.hh:84
Definition: symbtbl.hh:110
void output(FILE *out) const
Scope * scope
Definition: symbtbl.hh:93
Definition: symbtbl.hh:193
bool search_scopes(const char *, YSymbol *&) const
search current scope and all abov
const YSymbolTable::Scope * scope
Definition: symbtbl.hh:186
Definition: symbtbl.hh:192
YSymbol * last_symbol
Definition: symbtbl.hh:87
Definition: symbtbl.hh:113
Definition: symbtbl.hh:41
const YSymbol * pop_scope()
Definition: parse.hh:275
YLiteral value
Definition: symbtbl.hh:141
Scope * global_scope
Definition: symbtbl.hh:96
Definition: symbtbl.hh:195
const YSymbol * owner
Definition: symbtbl.hh:89
bool search_my_scope(const char *, const YSymbol *, YSymbol *&) const
search a specified scope of a symbol
void insert_symbol(YSymbol *) const
bool search_global_scope(const char *, YSymbol *&) const
search the global_scope
Definition: symbtbl.hh:191
const YSymbol * get_defining_symbol() const
get the symbol that defines this scope
Definition: parse.hh:193
Definition: symbtbl.hh:113
YSymbol * symbols
Definition: symbtbl.hh:86
Parse_enum::Enumerator * enumerator
Definition: symbtbl.hh:208
struct Scope * next
Definition: symbtbl.hh:84
bool search_this_scope(const char *, const Scope *, YSymbol *&) const
long Integer
Definition: symbtbl.hh:121
bool owned_by_symbol
defines wether this symbol is owned by another symbol or by a scope
Definition: symbtbl.hh:176
YConstant constant
Definition: symbtbl.hh:205
void push_scope(YSymbol *)
const char * String
Definition: symbtbl.hh:123
Definition: symbtbl.hh:78
YSymbol_type
Definition: symbtbl.hh:191
void insertData() const
Definition: symbtbl.hh:113
Parse_composite::Element * Attribute
Definition: symbtbl.hh:203
Definition: parse.hh:46
Definition: symbtbl.hh:194
Definition: symbtbl.hh:113
YSymbol * next
Definition: symbtbl.hh:184
enum YSymbol::YSymbol_type type
Definition: symbtbl.hh:157
bool search_scopes_above(const YSymbol *, YSymbol *&) const
search me all scopes above me, and not myself
Definition: symbtbl.hh:113
Definition: symbtbl.hh:138
bool search_scope(const char *, YSymbol *&) const
search only current scope
bool scoped_symbol(YSymbol **result, const char *name, const YWhere &where)
creates a symbol in the current scoped
const char * get_name() const
Definition: symbtbl.hh:168
enum YLiteral::Literal_type type
double Real
Definition: symbtbl.hh:119
char Character
Definition: symbtbl.hh:125
bool Boolean
Definition: symbtbl.hh:127
const YSymbolTable::Scope * defines
Definition: symbtbl.hh:188
Parse_type * type
Definition: symbtbl.hh:143
const YSymbol * get_symbol(const char *name) const
get the corresponding symbol to name
Literal_type
Definition: symbtbl.hh:113
struct Scope * up
Definition: symbtbl.hh:83