Expand description
The compiler for the Penne programming language.
This is the internal documentation for the Penne compiler.
General information about the Penne programming language,
its syntax and semantics
is found in the README.
Usage instructions for the command line interface can be found
by running penne help
from the command line.
The Abstract Syntax Tree is detailed in the modules common, value_type and resolved. Errors are laid out in error. The compiler stages are (in order): lexer, parser, expander, scoper, typer, analyzer, linter, resolver and generator. The rebuilder module allows turning the AST back into (annotated) code. The stdout module contains helper code for the command line interface.
Re-exports§
pub use error::Error;
pub use error::Errors;
pub use resolved::Declaration;
Modules§
- analyzer
- During the analysis stage, the common AST is checked for any additional syntax or semantical errors.
- common
- Most compiler stages share a common AST.
- error
- Compiler stages may generate syntax errors and semantical errors.
- expander
- During the import expansion stage, public symbols are shared between compilation units.
- generator
- The IR generation stage turns the resolved AST into LLVM IR.
- lexer
- The lexer cuts each line of source code into a sequence of tokens.
- linter
- The optional linting stage analyzes the common AST and generates warnings for error-free code that may have unintended behavior at runtime.
- parser
- The parser takes lexed tokens and builds the common AST.
- rebuilder
- As a debugging aid for compiler development, source code may be rebuilt from the common AST, potentially annotated with extra-syntactical markers.
- resolved
- The resolved AST contain no syntax or semantic errors and is ready for IR generation.
- resolver
- The resolution stage is the final compiler stage before IR generation. The result of this stage is either a sequence of resolved declarations, or a collection of all errors generated by earlier stages.
- scoper
- During the scoping stage, the validity of variable references, function calls and goto statements is determined.
- stdout
- The command line interface outputs colored dumps of intermediate code when run with the verbose flag.
- typer
- During the type inference stage, the types of values and variables are
determined, and
autoderef
expressions are inserted. - value_
type - Each variable, expression and return value has a ValueType.
Functions§
- compile_
source - Convience method that parses source code and runs it through each of the compiler stages.