项目作者: patrickfrey

项目描述 :
Compiler-compiler for writing compiler frontends with Lua
高级语言: C++
项目地址: git://github.com/patrickfrey/mewa.git
创建时间: 2020-08-20T13:13:59Z
项目社区:https://github.com/patrickfrey/mewa

开源协议:Other

下载


Imagine

… to define the typesystem of your language like this:

Pseudocode Class Declaration
  1. class Obj
  2. {
  3. function run( param : int ) -> int;
  4. }
Typedb Commands Illustration (Simplified)
  1. intType = typedb:def_type( 0, "int" )
  2. function call( func) return function( this, arg ) ... end end
  3. function init( obj) return function( address) ... end end
  4. object = typedb:def_type( 0, "Obj" )
  5. mt = typedb:def_type( object, "run" )
  6. run = typedb:def_type( mt, "()", call( "Obj_run"), {intType} )
  7. 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