Gyoji Compiler
Loading...
Searching...
No Matches
parse-result.hpp
1/* Copyright 2025 Jonathan S. Arney
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * https://github.com/jarney/gyoji/blob/master/LICENSE
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef _GYOJI_INTERNAL
16#error "This header is intended to be used internally as a part of the Gyoji front-end. Please include frontend.hpp instead."
17#endif
18#pragma once
19
20namespace Gyoji::frontend::yacc {
21 class YaccParser;
22 class LexContext;
23}
24
29namespace Gyoji::frontend {
30 class Parser;
31
32 class Symbol {
33 public:
34 Symbol(std::string _name, const Gyoji::context::SourceReference & _src_ref);
35 Symbol(const Symbol & _other);
36 ~Symbol();
37 std::string name;
39 };
40
68 public:
78 Gyoji::context::CompilerContext & _compiler_context,
80 );
85
94
99 bool has_errors() const;
100
106
114 bool has_translation_unit() const;
115
127
137
142
143 friend Gyoji::frontend::yacc::YaccParser;
144 friend Gyoji::frontend::yacc::LexContext;
146
147 void symbol_table_dump();
148
155 std::string name,
156 bool allow_placement_in_namespace,
157 const Gyoji::context::SourceReference & _src_ref
158 );
159
160 Gyoji::frontend::namespaces::NS2Entity *namespace_get_or_create(
161 std::string name,
162 const Gyoji::context::SourceReference & _src_ref
163 );
164
165 Gyoji::frontend::namespaces::NS2Entity* class_get_or_create(
166 std::string _name,
167 const Gyoji::context::SourceReference & _source_ref
168 );
169
170 Gyoji::frontend::namespaces::NS2Entity* type_get_or_create(
171 std::string _name,
172 const Gyoji::context::SourceReference & _source_ref
173 );
174
175
176 const Symbol *symbol_get_or_create(std::string symbol, const Gyoji::context::SourceReference & _src_ref);
177
178 void symbol_define(std::string symbol, const Gyoji::context::SourceReference & _src_ref);
190 const Symbol *symbol_get(std::string name) const;
191 private:
195 void set_translation_unit(Gyoji::owned<Gyoji::frontend::tree::TranslationUnit> tu);
196
197 Gyoji::context::CompilerContext & compiler_context;
198
200
202
215
216 // We probably need a 'symbol table' which keeps track of global
217 // variables and functions. The index would be the 'symbol name'
218 // which would consist of the unique name. For globals, this is just
219 // the symbol name as a fully qualified name. For functions, this is
220 // the fully namespace qualified name along with mangled argument list
221 // in C++ style. It should be C++ compatible mangling (maybe?)
222
223 // When we encounter an unqualified name, we try applying the current
224 // search space (usings) and current scopes, try variations on the
225 // name based on the path until we get a match. If there's no match, we're
226 // clear to create a new one.
227 };
228
229};
230
231
Compiler Context.
Definition gyoji-context.hpp:44
Container for errors reported.
Definition errors.hpp:145
References a location in the source-file.
Definition source-reference.hpp:30
Stream of tokens read by the parser to provide context for errors.
Definition token-stream.hpp:120
Definition parse-result.hpp:67
const Gyoji::frontend::tree::TranslationUnit & get_translation_unit() const
Definition parse-result.cpp:49
const Symbol * symbol_get(std::string name) const
Definition parse-result.cpp:86
Gyoji::context::Errors & get_errors() const
Definition parse-result.cpp:43
const Gyoji::context::TokenStream & get_token_stream() const
Definition parse-result.cpp:64
const Gyoji::context::CompilerContext & get_compiler_context() const
Definition parse-result.cpp:69
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:116
bool has_errors() const
Definition parse-result.cpp:58
bool has_translation_unit() const
Definition parse-result.cpp:54
~ParseResult()
Definition parse-result.cpp:33
const Gyoji::frontend::namespaces::NS2Context & get_ns2_context() const
Definition parse-result.cpp:37
Definition parser.hpp:33
Entity living inside a namespace.
Definition ns2.hpp:40
Represents the top-level syntax unit for a source file.
Definition tree.hpp:2889
This is the front-end to the Gyoji parser.
Definition gyoji-frontend.hpp:66