Expand description
Gruel compiler driver.
This crate orchestrates the compilation pipeline: Source -> Lexer -> Parser -> AstGen -> Sema -> CodeGen -> ELF
It re-exports types from the component crates for convenience.
§Diagnostic Formatting
The MultiFileFormatter provides a clean API for formatting errors and warnings:
ⓘ
use gruel_compiler::{MultiFileFormatter, SourceInfo, FileId};
let sources = vec![(FileId::new(1), SourceInfo::new(&source, "example.gruel"))];
let formatter = MultiFileFormatter::new(sources);
// Format an error
let error_output = formatter.format_error(&error);
eprintln!("{}", error_output);§Tracing
This crate is instrumented with tracing spans for performance analysis.
Use --log-level info or --time-passes to see timing information.
Structs§
- Air
- The complete AIR for a function.
- AirOutput
- Output from semantic analysis (compile_to_air).
- Analyzed
Function - Result of analyzing a function.
- Ast
- A complete source file (list of items).
- AstGen
- Generates RIR from an AST.
- Cfg
- The complete CFG for a function.
- CfgBuilder
- Builder that converts AIR to CFG.
- CfgOutput
- Output from CFG construction.
- Compilation
Unit - A unified compilation unit that owns all artifacts from source to machine code.
- Compile
Errors - A collection of compilation errors.
- Compile
Options - Configuration options for compilation.
- Compile
Output - Output from successful compilation.
- Compile
State - Intermediate compilation state after frontend processing.
- Compile
State From Rir - Intermediate compilation state after frontend processing from RIR.
- Diagnostic
- Rich diagnostic information for errors and warnings.
- Error
Code - A unique error code for each error type.
- FileId
- A file identifier used to track which source file a span belongs to.
- Function
- A function definition.
- Function
With Cfg - A function with its typed IR (AIR) and control flow graph (CFG).
- Json
Diagnostic - A diagnostic formatted for JSON output.
- Json
Span - A span in JSON format with file location and labels.
- Json
Suggestion - A suggested fix in JSON format.
- Lexer
- Logos-based lexer that converts source text into tokens.
- Merged
Program - Result of merging symbols from multiple parsed files.
- Multi
File Formatter - A diagnostic formatter that supports diagnostics spanning one or more source files.
- Multi
File Json Formatter - Formats diagnostics as JSON for machine consumption.
- Parsed
File - Result of parsing a single file.
- Parsed
Program - Result of parsing all source files.
- Parser
- Chumsky-based parser that converts tokens into an AST.
- Rir
- The complete RIR for a source file.
- RirPrinter
- Printer for RIR that resolves symbols to their string values.
- Sema
- Semantic analyzer that converts RIR to AIR.
- Sema
Output - Output from semantic analysis.
- Source
File - A source file with its path and content.
- Source
Info - Source code information for diagnostic rendering.
- Span
- A span representing a range in the source code.
- Spur
- The default key for every Rodeo, uses only 32 bits of space
- Struct
Def - Definition of a struct type.
- Suggestion
- A suggested code fix that can be applied to resolve a diagnostic.
- Threaded
Rodeo - A concurrent string interner that caches strings quickly with a minimal memory footprint,
returning a unique key to re-access it with
O(1)internment and resolution. - Token
- A token with its kind and source span.
- Type
- A type in the Gruel type system.
- Type
Intern Pool - Thread-safe intern pool for all composite types.
- Validated
Program - Result of validating and generating RIR from multiple parsed files.
Enums§
- Applicability
- How confident we are that a suggested fix is correct.
- Arch
- The CPU architecture of a target.
- Color
Choice - Color choice for diagnostic output.
- Error
Kind - The kind of compilation error.
- Expr
- An expression.
- Item
- A top-level item in a source file.
- Linker
Mode - Which linker to use for the final linking phase.
- OptLevel
- Optimization level, following standard compiler conventions.
- Preview
Feature - A preview feature that can be enabled with
--preview. - Target
- A compilation target consisting of an architecture and operating system.
- Token
Kind - Token kinds in the Gruel language.
- Warning
Kind - The kind of compilation warning.
Functions§
- compile
- Compile source code to an ELF binary.
- compile_
backend - Compile analyzed functions to a binary.
- compile_
frontend - Compile source code through all frontend phases (up to but not including codegen).
- compile_
frontend_ from_ ast - Compile from an already-parsed AST through all remaining frontend phases.
- compile_
frontend_ from_ ast_ with_ options - Compile from an already-parsed AST through all remaining frontend phases.
- compile_
frontend_ from_ ast_ with_ options_ full - Like
compile_frontend_from_ast_with_options, but additionally lets the caller suppress the on-the-fly stderr print of comptime@dbgoutput. - compile_
frontend_ from_ rir_ with_ file_ paths - Compile frontend from RIR with file paths for module resolution.
- compile_
frontend_ from_ rir_ with_ options - Compile from already-generated RIR through remaining frontend phases.
- compile_
frontend_ with_ options - Compile source code through all frontend phases.
- compile_
frontend_ with_ options_ full - Like
compile_frontend_with_options, but additionally lets the caller suppress the on-the-fly stderr print of comptime@dbgoutput. Whensuppress_comptime_dbg_printis true, output is only collected in theSemaOutput.comptime_dbg_outputbuffer. Used by fuzz harnesses that consume the buffer directly and don’t want noise on stderr. - compile_
multi_ file_ with_ options - Compile multiple source files to an ELF binary.
- compile_
to_ air - Compile source code up to AIR (typed IR) without building CFG.
- compile_
to_ cfg - Compile source code up to CFG (control flow graph).
- compile_
with_ options - Compile source code to an ELF binary with the given options.
- generate_
llvm_ ir - Generate LLVM textual IR from analyzed functions.
- merge_
symbols - Merge symbols from all parsed files into a unified program.
- parse_
all_ files - Parse multiple source files with a shared interner.
- validate_
and_ generate_ rir_ parallel - Validate symbols and generate RIR in parallel for multi-file compilation.
Type Aliases§
- Compile
Error - A compilation error with optional source location information.
- Compile
Result - Result type for compilation operations.
- Compile
Warning - A compilation warning with optional source location information.
- Multi
Error Result - Result type for operations that can produce multiple errors.
- Preview
Features - A set of enabled preview features.