Gyoji Compiler
Loading...
Searching...
No Matches
parse-result.hpp
1#ifndef _GYOJI_INTERNAL
2#error "This header is intended to be used internally as a part of the Gyoji front-end. Please include frontend.hpp instead."
3#endif
4#pragma once
5
6namespace Gyoji::frontend::yacc {
7 class YaccParser;
8 class LexContext;
9}
10
15namespace Gyoji::frontend {
16 class Parser;
17
18 class Symbol {
19 public:
20 Symbol(std::string _name, const Gyoji::context::SourceReference & _src_ref);
21 Symbol(const Symbol & _other);
22 ~Symbol();
23 std::string name;
25 };
26
54 public:
64 Gyoji::context::CompilerContext & _compiler_context,
66 );
71
80
85 bool has_errors() const;
86
92
100 bool has_translation_unit() const;
101
113
123
128
129 friend Gyoji::frontend::yacc::YaccParser;
130 friend Gyoji::frontend::yacc::LexContext;
132
133 void symbol_table_dump();
134
141 std::string name,
142 bool allow_placement_in_namespace,
143 const Gyoji::context::SourceReference & _src_ref
144 );
145
146 Gyoji::frontend::namespaces::NS2Entity *namespace_get_or_create(
147 std::string name,
148 const Gyoji::context::SourceReference & _src_ref
149 );
150
151 Gyoji::frontend::namespaces::NS2Entity* class_get_or_create(
152 std::string _name,
153 const Gyoji::context::SourceReference & _source_ref
154 );
155
156 Gyoji::frontend::namespaces::NS2Entity* type_get_or_create(
157 std::string _name,
158 const Gyoji::context::SourceReference & _source_ref
159 );
160
161
162 const Symbol *symbol_get_or_create(std::string symbol, const Gyoji::context::SourceReference & _src_ref);
163
164 void symbol_define(std::string symbol, const Gyoji::context::SourceReference & _src_ref);
176 const Symbol *symbol_get(std::string name) const;
177 private:
181 void set_translation_unit(Gyoji::owned<Gyoji::frontend::tree::TranslationUnit> tu);
182
183 Gyoji::context::CompilerContext & compiler_context;
184
186
188
201
202 // We probably need a 'symbol table' which keeps track of global
203 // variables and functions. The index would be the 'symbol name'
204 // which would consist of the unique name. For globals, this is just
205 // the symbol name as a fully qualified name. For functions, this is
206 // the fully namespace qualified name along with mangled argument list
207 // in C++ style. It should be C++ compatible mangling (maybe?)
208
209 // When we encounter an unqualified name, we try applying the current
210 // search space (usings) and current scopes, try variations on the
211 // name based on the path until we get a match. If there's no match, we're
212 // clear to create a new one.
213 };
214
215};
216
217
Compiler Context.
Definition gyoji-context.hpp:30
Container for errors reported.
Definition errors.hpp:131
References a location in the source-file.
Definition source-reference.hpp:16
Stream of tokens read by the parser to provide context for errors.
Definition token-stream.hpp:106
Definition parse-result.hpp:53
const Gyoji::frontend::tree::TranslationUnit & get_translation_unit() const
Definition parse-result.cpp:35
const Symbol * symbol_get(std::string name) const
Definition parse-result.cpp:72
Gyoji::context::Errors & get_errors() const
Definition parse-result.cpp:29
const Gyoji::context::TokenStream & get_token_stream() const
Definition parse-result.cpp:50
const Gyoji::context::CompilerContext & get_compiler_context() const
Definition parse-result.cpp:55
Gyoji::frontend::namespaces::NS2Entity * identifier_get_or_create(std::string name, bool allow_placement_in_namespace, const Gyoji::context::SourceReference &_src_ref)
Definition parse-result.cpp:102
bool has_errors() const
Definition parse-result.cpp:44
bool has_translation_unit() const
Definition parse-result.cpp:40
~ParseResult()
Definition parse-result.cpp:19
const Gyoji::frontend::namespaces::NS2Context & get_ns2_context() const
Definition parse-result.cpp:23
Definition parser.hpp:19
Entity living inside a namespace.
Definition ns2.hpp:26
Represents the top-level syntax unit for a source file.
Definition tree.hpp:2759
This is the front-end to the Gyoji parser.
Definition gyoji-frontend.hpp:52