Purely functional language for JVM platform with compiler written in Scala. The language is a subset of Scheme enriched with a JVM directive which implements Java interoperability - user can use functions from Java standard library. There are plenty of syntactic constructs that are handled only partially, but, e.g. following programs compile correctly:
(define fib (lambda (n) (if (<= n 2) 1 (+ (fib (- n 1)) (fib (- n 2))))))
(write (fib 6))
(write (JVM.String.length "Answer to the Ultimate Question of Life, the Universe, and Everything"))
(define nwd (lambda (a b) (if (= b 0) a (nwd b (% a b) ) ) ))
(write (nwd 133 32))
(write (nwd 42 56))
(write (nwd 100 100))
You can find more examples in the examples
directory.
scala 2.13
java 11
sbt
- Inside
singularity
directory runsbt assembly
. Fat jar will be built intarget
directory. - To compile the code, run
scala FAT_JAR FILE_WITH_CODE
whereFILE_WITH_CODE
contains valid code written in the language. - After executing the previous step directory named
WYNIK_KOMPILACJI
will be created. The directory name can be changed by altering the configuration parameters. cd
into newly created directory and issuejava Main
command to run the program.
- Lexer & parser
- Basic data types (int, str, float, char, bool)
- read and write instructions
- function invokation syntax
- if else then
- let exprs
- pattern matching
- ast traversal & bytecode gen
- main class with main method
- read and write bytecode gen
- function invokation
- if else then
- optimization & utility
- import native java classes
- recursion tco