Skip to content

patrickfrey/mewa

Repository files navigation

Imagine

... to define the typesystem of your language like this:

Pseudocode Class Declaration
class Obj
{
	function run( param : int ) -> int;
}
Typedb Commands Illustration (Simplified)
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

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.

Design Philosophy and Limitations

  • 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.

LLVM IR

The examples provided here use the intermediate representation (IR) of LLVM for code generation. For reading more see the collected links.

Status

I consider the software as ready for use in projects.

Portability

Build

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).

Target platforms

Issues around target platforms are discussed here.

Documentation

Mailing List

  • mewa at freelists

Chat

  • hash mewa-dev (registered channel) at libera chat

Website

Contact (E-Mail)

  • mail at mewa cc