https://github.com/styczynski/instant-compiler-go
https://github.com/styczynski/instant-compiler-go
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/styczynski/instant-compiler-go
- Owner: styczynski
- License: mit
- Created: 2021-11-03T19:28:32.000Z (over 4 years ago)
- Default Branch: compat
- Last Pushed: 2023-12-11T13:26:26.000Z (over 2 years ago)
- Last Synced: 2025-01-16T04:22:39.113Z (over 1 year ago)
- Language: Go
- Size: 94.1 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Instant compiler
[](https://github.com/styczynski/instant-compiler-go/actions/workflows/release.yml)
This project uses [go-project-blueprint](https://github.com/MartinHeinz/go-project-blueprint) as a starter project so
the original Dockerfile/go.mod and config comes from this repository.
I also utilize customized [chroma](https://github.com/alecthomas/chroma) code to provide syntax colouring.
The project itself implements Hindley-Milder typesystem, which were based on various reference papers and implemeneted by me so there's a little change the core code will be similar to what is seen in this reference documents.
The code itself is mine although orignally it was written for Latte compilation.
## Project strcture
- compiler - core compiler features
- errors - error handling
- compiler_pipeline - Compiler pipeline code (this folder contains all blocks like runner, compiler, type checker connected)
- events_collector - compiler async event colelction system
- events_utils - minor utilities for event collection
- generic_ast - AST implementation (the specification allows parsing and inference algotether)
- parser - parser implemetation
- input_reader - input pipeline abstraction
- printer - pretty-printing tilities
- runner - compiled code runner and tester
- type_checker - extended-HM inference implementation
## Building
To build the project simply call:
```bash
$ make
```
## Interactive CLI
You can run interactive CLI by typing:
```bash
$ ./insc_jvm shell
```
The interactive shell allows user to provide input program and realtime compiler output as well as running program output.
## Running
You can test bulk of files using glob:
```bash
$ ./insc_jvm --backend jvm './test/*.ins'
```
Or compile one at the time:
```bash
$ ./insc_jvm --backend llvm ./tests/a.ins
```
The compiler atomatically detects `*.valid_output` files and runs compiled program agains them to check for output correctnes.
That means thatyou can easily test the executable. You just have to copy all `*.valid_output` files to the specific directory and use './dir/\*.some_extension` glob for compiler input.
The extension is configrable by using `--runner-test-extension` parameter. Please type `./insc_jvm --help` or `./insc_llvm --help` to get more info.
For example if you wish to test all files in `tests/` diretory you can execute the following command:
```bash
$ ./insc_llvm --runner-test-extension output "./tests/*.ins"
$ ./insc_jvm --runner-test-extension output "./tests/*.ins"
```