Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/TechnoJo4/luadaul

A programming language that compiles to Lua.
https://github.com/TechnoJo4/luadaul

compiler lua luajit

Last synced: 3 months ago
JSON representation

A programming language that compiles to Lua.

Awesome Lists containing this project

README

        

# daul



daul is a language that transpiles to Lua. It aims to simplify the use of
functional-style code by eliminating the distinction between statements and
expressions.

Daul Generated/Equivalent Lua code

Tables:
```kotlin
// Use [] instead of {}
val arr = [ 1, 2, 3 ]

// Use "key:" instead of "[key] ="
val tbl = [ "arr": arr ]
val zeroindexed = [ 0: 1, 2, 3 ];
```

```lua
local arr={1,2,3};
local tbl={["arr"]=arr};
local zeroindexed={[0]=1,2,3};
```

Statements and blocks:
```kotlin
// Example TODO
```

```lua
-- Example TODO
```

Constant variables:
```kotlin
var x = 0
x = 1
val y = 2
y = 3
```

Compiler error:
```
4 | y = 3
~
Variable 'y' was declared as constant (val)
```

Functions:
```kotlin
val f1 = \arg1, arg2 -> {
print(arg1)
arg1 + arg2
}

// Block can be omitted for a single expression
val f2 = \x -> 1+x

// Arguments can be omitted when there are none
val f3 = \[ "a": "b" ]
val f4 = \{
print("f4")
f3()
}
```

```lua
local f1 = (function(arg1,arg2)
print(arg1);
return (arg1+arg2);
end);

local f2 = (function(x)
return (1+x);
end);

local f3 = (function()
return {["a"]="b"};
end);

local f4 = (function()
print("f4");
return f3();
end);
```