This is a very small subset of language1, only static structures and first class scalar types.
- No memory allocation, only scalar types, constant strings and static structures (named classes) as data types
- Classes (no constructors, no destructors, no inheritance, only methods)
- Free procedures and functions
- Backend is LLVM IR
This language has been designed to explain Mewa. It is not considered as a code-base for a larger project. You shouldn't use the examples presented here as a code-base anyway. The examples, together with the FAQ can help you planning your compiler project. With a layout, you can do a much better job than me. I was cutting my way through the jungle with a machete. You have the overview.
The project specific files of the example language presented in the article Writing Compiler Front-Ends for LLVM with Lua using Mewa are located in examples/intro
- grammar.g Grammar description in a kind of BNF with Lua function calls to the typesystem module writen in Lua as attributes.
- llvmir.lua Format templates organized in structures for producing LLVM output.
- llvmir_scalar.lua GENERATED FILE. Format templates organized in structures for the built-in basic first class scalar types.
- scalar_types.txt Descriptions of the built-in basic first class scalar types.
- typesystem.lua Implements the Lua AST node functions, the functions defined as production attributes of the grammar. For better presentability in an article, this module is divided into snippets included with the Lua
dofile
command. The snippets implementing AST node functions are located in the subdirectory ast. The snippets implementing the functionality are located in the subdirectory sections
- program.prg Demo program.