https://github.com/redstar/m2lang
The LLVM-based Modula-2 compiler
https://github.com/redstar/m2lang
ast-generator compiler llvm llvm-frontend modula-2 parser-generator
Last synced: 10 months ago
JSON representation
The LLVM-based Modula-2 compiler
- Host: GitHub
- URL: https://github.com/redstar/m2lang
- Owner: redstar
- License: other
- Created: 2019-02-02T21:06:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T23:48:27.000Z (about 1 year ago)
- Last Synced: 2025-04-09T19:19:39.581Z (10 months ago)
- Topics: ast-generator, compiler, llvm, llvm-frontend, modula-2, parser-generator
- Language: C++
- Homepage:
- Size: 1.31 MB
- Stars: 71
- Watchers: 13
- Forks: 13
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
m2lang - The LLVM-based Modula-2 compiler
=========================================
[][1]
Introduction
------------
See this [FOSDEM 2019 talk](https://fosdem.org/2019/schedule/event/llvm_irgen/) for some details.
Implementation decisions
------------------------
- LLVM is only external dependency
- Uses C++20 modules
- xmake for building
- ISO Modula-2 language first
- Usea "declare-before-use" (single-pass) model
- Goal is target several platforms from the beginning
Current status
--------------
- The lexer is done.
- The preprocessor (for handling of directives) is is based on the draft
technical report ["Interfacing Modula-2 to C", Annex B](http://www.zi.biologie.uni-muenchen.de/~enger/SC22WG13/im2c-981130.html#TR-AXI-PRAGMAS)
and aims to be compatible to the [Macintosh p1 compiler](https://modula2.awiedemann.de/manual/comp4.html#L4_2).
Parsing of directives is implemented, with mostly no functionality.
- The parser is based on ISO Modula-2 with generic and OO additions.
Some LL(1) conflicts are still left in the grammar, so not every source is parsed correctly.
- The parser is generated by [LLtool](https://github.com/redstar/LLtool). A C++
port of LLtool is now integrated into this project, but not yet enabled.
- Error recovery in the parser is based on "panic mode", using the follow sets
of the current and the active callers.
- The AST nodes are generated by [ASTtool](lib/ASTtool).
- Error messages are outputted using llvm::SourceMgr for nice presentation.
- Only a dummy driver exists to see the parser in action.
- A couple of IR statements is emitted to the console after succesful parsing.
[1]: https://cirrus-ci.com/github/redstar/m2lang "Cirrus CI Build Status"