Skip to content

Commit

Permalink
Big commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor authored and Victor committed Jul 27, 2024
1 parent fab1617 commit 6610ebd
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 970 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vscode:
rm -rf ~/.vscode/extensions/maeel-syntax-highlighting 2>/dev/null && cp -r editor_impls/vscode ~/.vscode/extensions/maeel-syntax-highlighting

test:
rustc src/maeel.rs -o maeel && ./maeel run tests.maeel
rustc src/maeel.rs -o maeel && ./maeel tests.maeel

bench:
rustc src/maeel.rs -o maeel && hyperfine --runs 1000 "./maeel run tests.maeel"
rustc src/maeel.rs -o maeel && hyperfine --runs 1000 "./maeel tests.maeel"
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

The interpreter is made of ~ 600 lines of code :3 Indeed a lot of maeel features are implemented in itself (stack functions, while loop, for loop, arrays, functional programming utilities...) (c.f. [maeel.maeel](maeel.maeel))

## Project advancement

- Lexer: `100%`
- Interpreter: `90%`
- Compiler: `10%`

## Compile

`$ make test` (c.f. [tests.maeel](./stdlib/tests.maeel))
Expand All @@ -22,13 +16,7 @@ The interpreter is made of ~ 600 lines of code :3 Indeed a lot of maeel features

## Run program

`$ ./maeel run program.maeel`

## Other commands

`$ ./maeel tokenize program.maeel` (Parse program tokens)
`$ ./maeel compile program.maeel` (Compile to x86_64 assembly)
`$ ./maeel check program.maeel` (Type checking)
`$ ./maeel program.maeel`

## Hello, world!

Expand Down
6 changes: 4 additions & 2 deletions examples/08_fib.maeel
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include "maeel"

fun fib n [Int -> Int] (n 1< (1) (n 1- fib n 2- fib +) ifelse)
fun fib_rec n (
n 1< (1) (n 1- fib_rec n 2- fib_rec +) ifelse
)

1 10 range (fib) map putsln
1 10 range (fib_rec) map putsln
8 changes: 0 additions & 8 deletions examples/09_bad_types.maeel

This file was deleted.

19 changes: 4 additions & 15 deletions src/maeel.maeel
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fun ifelse (1 rot 0 swap take4 match!)
# Example:
# - ``` 1 1 and ``` will return 1 (true)
# - ``` 1 0 and ``` will return 0 (false)
fun inline and [Int Int -> Int] (*)
fun inline and (*)

# Or function
# Usage: a b or
Expand All @@ -286,7 +286,7 @@ fun inline and [Int Int -> Int] (*)
# Example:
# - ``` 1 0 or ``` will return 1 (true)
# - ``` 0 0 or ``` will return 0 (false)
fun inline or [Int Int -> Int] (+ 0= 1 swap-)
fun inline or (+ 0= 1 swap-)

# Not function
# Usage: a not
Expand All @@ -296,7 +296,7 @@ fun inline or [Int Int -> Int] (+ 0= 1 swap-)
# Example:
# - ``` 1 not ``` will return 0 (false)
# - ``` 0 not ``` will return 1 (true)
fun inline not [Int -> Int] (1 swap-)
fun inline not (1 swap-)

# Xor function
# Usage: a b xor
Expand All @@ -306,7 +306,7 @@ fun inline not [Int -> Int] (1 swap-)
# Example:
# - ``` 1 0 xor ``` will return 1 (true)
# - ``` 1 1 xor ``` will return 0 (false)
fun inline xor [Int Int -> Int] (+ 2 %)
fun inline xor (+ 2 %)

fun inline pom (dup not)

Expand Down Expand Up @@ -416,14 +416,3 @@ fun inline int (
match+
) for
)

# Unix_random_numbers function
# Usage: n mod unix_random_numbers
#
# Generates n random numbers from /dev/random and maps them to the range [0, mod).
#
# Example:
# - ``` 5 100 unix_random_numbers ``` will return 5 random numbers between 0 and 99.
fun unix_random_numbers n mod (
"/dev/random" n read (mod %) map
)
Loading

0 comments on commit 6610ebd

Please sign in to comment.