aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 389544ed799b7e8f098f5746d129c773b5577e8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Micro

This is not necessarily related to [Micro](https://git.usebox.net/micro-lang/about/), but I couldn't find a better name.

Micro is a small statically typed toy programming language.

Objectives:

* Learn Haskell and have fun
* Build a compiler
* (may be) Targeting 8-bit microcomputers (Z80 CPU); easy to interact with existing code written in C/ASM
* (may be) Targeting WASM
* Fast compilation
* Statically typed, small but useful, and reasonably performant (including on the target)

## Current status

This is a **work in progress**.

Check the [language spec](language.md) for a taste of what is planned.

Currently the compiler uses parsec (Monadic parser combinators) following this planned pipeline:

* Frontend
    - Lexer; lexical analysis
    - Parser; syntax analysis
    - Analyzer; semantic analysis, type-check, fold constant, etc
* Backend
    - Generator: emit intermediate code for the target (e.g. ASM files); (maybe) Intermediate representation

For updates, please check [Micro website](https://git.usebox.net/micro-lang-hs/about/).

## How to build it

Requires Haskel and Cabal:

```
cabal run micro
```

To run the tests use:

```
cabal test
```

## Running the compiler

TODO

### How does it look like?

This is an example of a Micro program:

```
def fib(n: u16): u16 {
    if n < 2 {
        return n;
    } else {
        return fib(n - 1) + fib(n - 2);
    }
}

fib(20); # 6765
```

### COPYING

This software is distributed under licence GPL, unless stated otherwise. It covers only *this* software, your programs are yours to license in any way you want.

See [COPYING](COPYING) file for further details.