Modules
The MotorScript compiler is split up into many different and independent modules. Since the compiler is written in Kotlin, and therefore targets the JVM platform, we can make use of the Java Modules system (introduced with Java 9). That is exactly what all the compiler modules are: each compiler module is its own separate Java module.
Compiler steps are roughly equivalent to these modules, in the way that each compiler step is located in one module, but not necessarily the other way around.
See the other pages in the menu for in-depth explanations of each step.
Currently, the following steps exist (with a brief description):
cli: Command Line Interface interface, handles all things related to CLIbuildmgr: Manages the entire build processdiscover: Source file discovery, dependency discoverylexparse: Contains ANTLRv4 generated parser, responsible for lexing and parsing source filefront: Font-end, IR generationcheck: Type checking and resolvingtransform: (?) Transformation of built-in functions into IRgen: Back-end, generates e.g..mcfunctionfiles and data packs
Flow
The following structure globally indicates how the different steps are executed in the process of compiling a project.
cliis called with CLI arguments, by means of executing the compiler executable.cliparses the CLI arguments and tries to load the build configuration from the specified source directory.buildmgris called bycliwith the build configuration just loaded.discoveris called bybuildmgr, in order to discover all source files and resolve dependencies.lexparseis called bybuildmgrwith the result from thediscoverstep, it will transform all sources into parse trees. It will also report any syntax errors that may be present. All of this is mostly off-loaded to the lexer and parser generated by ANTLRv4.frontis called bybuildmgrto transform all parse trees into IR.- If everything is still OK at this point in time,
buildmgrwill perform the following steps for each target:checkis called to resolve all references and perform type-checking.- (?)
transformis called to let all built-in constructs be transformed into IR. genis called to generate the final build artifacts (generally a data pack).