An open API service indexing awesome lists of open source software.

https://github.com/olekscode/tinylang

An interpreter for Tiny Language implemented in Scala
https://github.com/olekscode/tinylang

application evaluation interpreter

Last synced: 4 months ago
JSON representation

An interpreter for Tiny Language implemented in Scala

Awesome Lists containing this project

README

          

# TinyLang

**Example:** Computing the factorial with TinyLang

```Scala
val machine = new Machine
val env = Map("x" -> 5)

val code = Sequence(
Assign("factorial", Number(1)),
While(
Less(Number(1), Var("x")),
Sequence(
Assign("factorial", Prod(Var("factorial"), Var("x"))),
Assign("x", Sum(Var("x"), Number(-1)))
)
)
)

machine.run(code, env)
//res0: Map[String,Any] = Map(x -> 1, factorial -> 120)
```