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
Modules
During the analysis stage, the common AST is checked for any additional
syntax or semantical errors.
Most compiler stages share a common AST.
Compiler stages may generate syntax errors and semantical errors.
During the import expansion stage, public symbols are shared between
compilation units.
The IR generation stage turns the resolved AST into LLVM IR.
The lexer cuts each line of source code into a sequence of tokens.
The optional linting stage analyzes the common AST and generates warnings
for error-free code that may have unintended behavior at runtime.
The parser takes lexed tokens and builds the common AST.
As a debugging aid for compiler development, source code may be rebuilt
from the common AST, potentially annotated with extra-syntactical markers.
The resolved AST contain no syntax or semantic errors and is ready for
IR generation.
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.
During the scoping stage, the validity of variable references,
function calls and goto statements is determined.
The command line interface outputs colored dumps of intermediate code
when run with the verbose flag.
During the type inference stage, the types of values and variables are
determined, and
autoderef expressions are inserted.Each variable, expression and return value has a ValueType.
Functions
Convience method that parses source code and runs it through each of the
compiler stages.