Skip to main content

Crate formalang

Crate formalang 

Source
Expand description

§FormaLang

A compiler frontend library for the FormaLang declarative language. Parsing, semantic analysis, and IR lowering are built-in; code generation is the responsibility of embedders via the plugin system.

§Entry points

§Plugin system

Embedders compose IrPass transforms and a Backend via Pipeline. Built-in passes live in ir::DeadCodeEliminationPass and ir::ConstantFoldingPass.

Re-exports§

pub use ast::Definition;
pub use ast::Expr;
pub use ast::File;
pub use ast::Ident;
pub use ast::Statement;
pub use ast::Type;
pub use error::CompilerError;
pub use ir::simple_type_name;
pub use ir::EnumId;
pub use ir::FunctionId;
pub use ir::GenericBase;
pub use ir::ImportedKind;
pub use ir::IrFunction;
pub use ir::IrFunctionParam;
pub use ir::IrFunctionSig;
pub use ir::IrImport;
pub use ir::IrImportItem;
pub use ir::IrModule;
pub use ir::ResolvedType;
pub use ir::StructId;
pub use ir::TraitId;
pub use lexer::Lexer;
pub use lexer::Token;
pub use location::Location;
pub use location::Span;
pub use parser::parse_file;
pub use parser::parse_file_with_source;
pub use pipeline::Backend;
pub use pipeline::IrPass;
pub use pipeline::Pipeline;
pub use pipeline::PipelineError;
pub use reporting::report_error;
pub use reporting::report_errors;
pub use semantic::module_resolver::FileSystemResolver;
pub use semantic::SemanticAnalyzer;

Modules§

ast
Abstract Syntax Tree (AST) for FormaLang
error
ir
Intermediate Representation (IR) for FormaLang
lexer
location
parser
pipeline
Backend pipeline for IR transformation and code generation.
reporting
semantic
Semantic analysis (validation only — no evaluation or expansion).

Functions§

compile_and_report
Compile to IR, formatting errors as a human-readable report on failure.
compile_to_ir
Compile FormaLang source code into an IR module.
compile_to_ir_with_path
Compile FormaLang source to IR with a known source-file path.
compile_to_ir_with_path_and_resolver
Compile FormaLang source to IR with both a custom resolver and a known source-file path.
compile_to_ir_with_resolver
Compile FormaLang source code to IR with a custom module resolver.
compile_with_analyzer
Compile and return both the AST and the semantic analyzer.
compile_with_analyzer_and_resolver
Compile with a custom resolver, returning both AST and analyzer.
parse_only
Parse FormaLang source without semantic analysis.