Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Compiler_AST.H File Reference

Arena-backed AST node model for the compiler-support MVP. More...

#include <sstream>
#include <string>
#include <string_view>
#include <utility>
#include <Compiler_Token.H>
#include <ah-arena.H>
#include <ah-errors.H>
#include <tpl_dynArray.H>
Include dependency graph for Compiler_AST.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::Compiler_Ast_Node
 Abstract base class for all AST nodes. More...
 
class  Aleph::Compiler_Ast_Context
 Arena-backed ownership context for AST nodes. More...
 
struct  Aleph::Compiler_Ast_Context::Owned_Object
 Internal tracking for objects with destructors. More...
 
struct  Aleph::Compiler_Expr
 Abstract base class for expression nodes. More...
 
struct  Aleph::Compiler_Stmt
 Abstract base class for statement nodes. More...
 
struct  Aleph::Compiler_Type_Expr
 Abstract base class for parsed type-annotation syntax. More...
 
struct  Aleph::Compiler_Invalid_Type_Expr
 Placeholder node for type syntax that failed to parse. More...
 
struct  Aleph::Compiler_Named_Type_Expr
 Named type syntax such as Int, Bool, or T. More...
 
struct  Aleph::Compiler_Tuple_Type_Expr
 Tuple type syntax such as (Int, Bool). More...
 
struct  Aleph::Compiler_Function_Type_Expr
 Function type syntax such as fn(Int, T) -> Bool. More...
 
struct  Aleph::Compiler_Import_Decl
 Abstract base class for top-level import declarations. More...
 
struct  Aleph::Compiler_Invalid_Import_Decl
 Placeholder node for malformed import declarations. More...
 
struct  Aleph::Compiler_Source_Import_Decl
 Top-level import declaration naming one other source unit. More...
 
struct  Aleph::Compiler_Struct_Field
 One named field inside a parsed struct declaration. More...
 
struct  Aleph::Compiler_Enum_Variant
 One named variant inside a parsed enum declaration. More...
 
struct  Aleph::Compiler_Type_Decl
 Abstract base class for top-level type declarations. More...
 
struct  Aleph::Compiler_Invalid_Type_Decl
 Placeholder node for malformed type declarations. More...
 
struct  Aleph::Compiler_Type_Alias_Decl
 Transparent top-level type alias declaration. More...
 
struct  Aleph::Compiler_Struct_Decl
 Nominal top-level struct declaration. More...
 
struct  Aleph::Compiler_Enum_Decl
 Nominal top-level enum declaration with unit variants. More...
 
struct  Aleph::Compiler_Invalid_Expr
 Placeholder node for expressions that failed to parse. More...
 
struct  Aleph::Compiler_Identifier_Expr
 Node representing a named identifier reference. More...
 
struct  Aleph::Compiler_Literal_Expr
 Node representing a literal value. More...
 
struct  Aleph::Compiler_Grouping_Expr
 Node representing an expression explicitly wrapped in parentheses. More...
 
struct  Aleph::Compiler_Unary_Expr
 Node representing a prefix unary operation. More...
 
struct  Aleph::Compiler_Binary_Expr
 Node representing an infix binary operation. More...
 
struct  Aleph::Compiler_Call_Expr
 Node representing a function or method call. More...
 
struct  Aleph::Compiler_Invalid_Stmt
 Placeholder node for statements that failed to parse. More...
 
struct  Aleph::Compiler_Expr_Stmt
 Node representing an expression evaluated as a statement. More...
 
struct  Aleph::Compiler_Let_Stmt
 Node representing a local variable binding. More...
 
struct  Aleph::Compiler_Return_Stmt
 Node representing a return from the current function. More...
 
struct  Aleph::Compiler_Block_Stmt
 Node representing a braced sequence of statements. More...
 
struct  Aleph::Compiler_If_Stmt
 Node representing a conditional branch. More...
 
struct  Aleph::Compiler_While_Stmt
 Node representing a while-loop. More...
 
struct  Aleph::Compiler_Break_Stmt
 Node representing a loop break. More...
 
struct  Aleph::Compiler_Continue_Stmt
 Node representing a loop continuation. More...
 
struct  Aleph::Compiler_Param
 Representation of a function parameter. More...
 
struct  Aleph::Compiler_Function_Decl
 Node representing a top-level function declaration. More...
 
struct  Aleph::Compiler_Module
 Node representing a complete translation unit or module. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::Compiler_Ast_Detail
 

Enumerations

enum class  Aleph::Compiler_Expr_Kind {
  Aleph::Invalid , Aleph::Identifier , Aleph::Integer_Literal , Aleph::String_Literal ,
  Aleph::Char_Literal , Aleph::Bool_Literal , Aleph::Grouping , Aleph::Unary ,
  Aleph::Binary , Aleph::Call
}
 Enumeration of expression node kinds. More...
 
enum class  Aleph::Compiler_Stmt_Kind {
  Aleph::Invalid , Aleph::Expr , Aleph::Let , Aleph::Return ,
  Aleph::Block , Aleph::If , Aleph::While , Aleph::Break ,
  Aleph::Continue
}
 Enumeration of statement node kinds. More...
 
enum class  Aleph::Compiler_Type_Expr_Kind { Aleph::Invalid , Aleph::Named , Aleph::Tuple , Aleph::Function }
 Enumeration of parsed type-expression node kinds. More...
 
enum class  Aleph::Compiler_Type_Decl_Kind { Aleph::Invalid , Aleph::Alias , Aleph::Struct , Aleph::Enum }
 Enumeration of top-level type declaration node kinds. More...
 
enum class  Aleph::Compiler_Import_Decl_Kind { Aleph::Invalid , Aleph::Import }
 Enumeration of top-level import declaration node kinds. More...
 

Functions

Source_Span Aleph::compiler_merge_spans (const Source_Span &lhs, const Source_Span &rhs) noexcept
 Merges two spans from the same source file.
 
const char * Aleph::compiler_expr_kind_name (const Compiler_Expr_Kind kind) noexcept
 Returns a stable debug name for an expression kind.
 
const char * Aleph::compiler_stmt_kind_name (const Compiler_Stmt_Kind kind) noexcept
 Returns a stable debug name for a statement kind.
 
const char * Aleph::compiler_type_expr_kind_name (const Compiler_Type_Expr_Kind kind) noexcept
 Returns a stable debug name for a type-expression kind.
 
const char * Aleph::compiler_type_decl_kind_name (const Compiler_Type_Decl_Kind kind) noexcept
 Returns a stable debug name for a type-declaration kind.
 
std::string Aleph::Compiler_Ast_Detail::escape_text (std::string_view text)
 Escapes control characters in a string for safe text output.
 
void Aleph::Compiler_Ast_Detail::dump_type_expr (const Compiler_Type_Expr *type, std::ostream &out)
 Dumps one parsed type-expression in a compact stable form.
 
void Aleph::Compiler_Ast_Detail::append_indent (std::ostream &out, const size_t indent)
 Utility to append spaces to a stream for indentation.
 
void Aleph::Compiler_Ast_Detail::dump_type_decl (const Compiler_Type_Decl *decl, std::ostream &out, const size_t indent)
 Recursive type-declaration printer for internal use.
 
void Aleph::Compiler_Ast_Detail::dump_expr (const Compiler_Expr *expr, std::ostream &out, const size_t indent)
 Recursive expression printer for internal use.
 
void Aleph::Compiler_Ast_Detail::dump_stmt (const Compiler_Stmt *stmt, std::ostream &out, const size_t indent)
 Recursive statement printer for internal use.
 
void Aleph::Compiler_Ast_Detail::dump_import_decl (const Compiler_Import_Decl *decl, std::ostream &out, const size_t indent)
 
std::string Aleph::compiler_dump_expr (const Compiler_Expr *expr)
 Dumps an expression subtree in a deterministic text format.
 
std::string Aleph::compiler_dump_stmt (const Compiler_Stmt *stmt)
 Dumps a statement subtree in a deterministic text format.
 
std::string Aleph::compiler_dump_import_decl (const Compiler_Import_Decl *decl)
 Dumps an import declaration subtree in a deterministic text format.
 
std::string Aleph::compiler_dump_type_decl (const Compiler_Type_Decl *decl)
 Dumps a type declaration subtree in a deterministic text format.
 
std::string Aleph::compiler_dump_function (const Compiler_Function_Decl *fn)
 Dumps a function declaration in a deterministic text format.
 
std::string Aleph::compiler_dump_module (const Compiler_Module *module)
 Dumps a parsed module in a deterministic text format.
 

Detailed Description

Arena-backed AST node model for the compiler-support MVP.

This header defines a small typed Abstract Syntax Tree (AST) for expressions, statements, type annotations, import/type/function declarations, and modules. Nodes are allocated through Compiler_Ast_Context and remain valid until the context is reset or destroyed.

The current grammar-oriented AST is intentionally compact: it covers the language surface parsed by Compiler_Parser.H without committing yet to a richer semantic layer.

Definition in file Compiler_AST.H.