Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Compiler_Frontend.H
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 version 2.0.0b
6 https://github.com/lrleon/Aleph-w
7
8 This file is part of Aleph-w library
9
10 Copyright (c) 2002-2026 Leandro Rabindranath Leon
11
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files (the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29*/
30
43#ifndef COMPILER_FRONTEND_H
44#define COMPILER_FRONTEND_H
45
46#include <string_view>
47
49#include <Compiler_IR_Model.H>
52#include <ah-diagnostics.H>
53
54namespace Aleph
55{
58 {
59 public:
60 virtual ~Compiler_Frontend() = default;
61
63 [[nodiscard]] virtual const char *
65
67 virtual void
69
75 virtual bool
77
79 virtual bool
80 parse() = 0;
81
83 virtual bool
84 analyze() = 0;
85
87 virtual bool
88 lower_hir() = 0;
89
96 virtual bool
97 lower_ir() = 0;
98
102
106
113
117
121
128 {
129 static const DynArray<Compiler_Module_Descriptor> empty;
130 return empty;
131 }
132
137 [[nodiscard]] virtual const DynArray<size_t> &
139 {
140 static const DynArray<size_t> empty;
141 return empty;
142 }
143
151 {
152 static const DynArray<Compiler_Module_Metadata> empty;
153 return empty;
154 }
155
159
162 find_artifact(std::string_view label) const noexcept = 0;
163
165 [[nodiscard]] virtual const DynArray<std::string> &
167
169 [[nodiscard]] virtual const DynArray<std::string> &
171 };
172}
173
174#endif
Shared contracts used by reusable compiler frontends and drivers.
Reusable explicit-value IR model, validation, and deterministic dumps.
Reusable metadata for parsed or analyzed module surfaces.
Reusable source-name module dependency resolution helpers.
Plain-text diagnostic engine for compiler-style tooling.
Abstract language frontend that can feed reusable drivers.
virtual bool analyze()=0
Runs semantic analysis on the parsed program.
virtual const Compiler_Type_Context * type_context() const noexcept=0
Returns the optional shared type context for dumps and backends.
virtual bool lower_hir()=0
Lowers the analyzed program into common HIR.
virtual const DynArray< std::string > & errors() const noexcept=0
Returns hard frontend-level errors outside the diagnostic engine.
virtual const Compiler_Driver_Artifact * find_artifact(std::string_view label) const noexcept=0
Finds one frontend artifact by exact label.
virtual const DynArray< Compiler_Driver_Artifact > & artifacts() const noexcept=0
Returns all frontend-produced artifacts from the last run.
virtual const DynArray< Compiler_Module_Descriptor > & module_descriptors() const noexcept
Returns parsed module descriptors for reusable import orchestration.
virtual void clear() noexcept=0
Clears all frontend-owned state from the previous run.
virtual bool load_sources(const DynArray< Compiler_Driver_Source > &inputs)=0
Registers the ordered input sources for the next run.
virtual const DynArray< size_t > & module_merge_order() const noexcept
Returns the dependency-first merge order from the last parse.
virtual const char * name() const noexcept=0
Returns a stable user-facing frontend name.
virtual ~Compiler_Frontend()=default
virtual const Compiler_IR_Module * ir_module() const noexcept=0
Returns the lowered IR module from the last run, when available.
virtual const Compiler_HIR_Module * hir_module() const noexcept=0
Returns the lowered HIR module from the last run, when available.
virtual const DynArray< Compiler_Module_Metadata > & module_metadata() const noexcept
Returns reusable metadata for the top-level surface of each module.
virtual bool lower_ir()=0
Lowers the analyzed program into common IR.
virtual const DynArray< std::string > & warnings() const noexcept=0
Returns non-fatal frontend-level warnings.
virtual Diagnostic_Engine * diagnostic_engine() noexcept=0
Returns the diagnostic engine populated by the frontend.
virtual bool parse()=0
Parses all previously loaded sources.
Context owning all compiler type nodes.
Diagnostic accumulator and renderer.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
STL namespace.
Stable text artifact produced during one pipeline run.
One logical input source handled by a compiler frontend.
Lowered IR module with shared global slots and functions.
One module descriptor consumed by the reusable resolver.