... to define the typesystem of your language like this:
class Obj
{
function run( param : int ) -> int;
}
intType = typedb:def_type( 0, "int" )
function call( func) return function( this, arg ) ... end end
function init( obj) return function( address) ... end end
object = typedb:def_type( 0, "Obj" )
mt = typedb:def_type( object, "run" )
run = typedb:def_type( mt, "()", call( "Obj_run"), {intType} )
typedb:def_reduction( intType, run, init( intType) )
Mewa is a compiler-compiler for prototyping of compiler front-ends for statically-typed programming languages in Lua. You write an attributed grammar in a custom language, a sort of Bison/Yacc-style BNF. The parser creates an AST (Abstract Syntax Tree) with a fixed schema. Lua function calls attached as attributes are called on the AST tree traversal triggered by the compiler after the syntax analysis. A Lua module written in C (see typedb API) provides assistance to define the type system of your programming language in a declarative way.
- Mewa is not a framework. It is not instrumented with configuration or plug-ins. The program logic is entirely implemented by the compiler front-end author in Lua. In other words: You write the compiler front-end with Lua using Mewa and not with Mewa using Lua as binding language.
- Mewa is not optimized for collaborative work.
- Mewa provides no support for the evaluation of different paths of code generation. It leaves all analytical optimization steps to the backend.
- Mewa is file-in, file-out, and not suited for implementing Jit compilation.
- Mewa does not aim to offer you the greatest variety of possibilities. There exist feature-richer compiler-compilers. Mewa aims to bring projects considered endless for a single person within reach.
The examples provided here use the intermediate representation (IR) of LLVM for code generation. For reading more see the collected links.
I consider the software as ready for use in projects.
Currently, there is only GNU Makefile support. CMake support is not planned for this project because the project is too small to justify it and it has not many dependencies. I would rather like to have Makefiles for platforms where GNU Makefile support is not available (e.g. Windows).
Issues around target platforms are discussed here.
- Intro with a Tutorial
- Examples
- Installation
- Glossary
- Grammar Description Language
- Parser Generator
- Bridges to Other Tools
- API
- AST (Abstract Syntax Tree) Format
- Error Codes
- FAQ
- Algorithms
- Links
- Wishlist for LLVM IR
- TODO
- mewa at freelists
- hash mewa-dev (registered channel) at libera chat
- mail at mewa cc