mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 17:59:30 +00:00
v0.4.0
Updated README and tests
This commit is contained in:
parent
9b809fc8a4
commit
01ff6e6240
2 changed files with 48 additions and 1 deletions
27
README.md
27
README.md
|
|
@ -32,7 +32,7 @@ end)
|
|||
````
|
||||
|
||||
#### Quick setup
|
||||
Install Candran automatically using LuaRocks: ```sudo luarocks install candran```.
|
||||
Install Candran automatically using LuaRocks: ```sudo luarocks install rockspec/candran-0.4.0-1.rockspec```.
|
||||
|
||||
Or manually install LPegLabel (```luarocks install LPegLabel```), download this repository and use Candran through the scripts in ```bin/``` or use it as a library with the self-contained ```candran.lua```.
|
||||
|
||||
|
|
@ -129,6 +129,31 @@ Anonymous function (functions values) can be created in a more concise way by om
|
|||
|
||||
A ```:``` can prefix the parameters paranthesis to automatically add a ```self``` parameter.
|
||||
|
||||
##### let variable declaration
|
||||
```lua
|
||||
let a = {
|
||||
foo = function()
|
||||
print(type(a)) -- table
|
||||
end
|
||||
}
|
||||
```
|
||||
|
||||
Similar to ```local```, but the variable will be declared *before* the assignemnt (i.e. it will compile into ```local a; a = value```), so you can access it from functions defined in the value.
|
||||
|
||||
Can also be used as a shorter name for ```local```.
|
||||
|
||||
##### continue keyword
|
||||
```lua
|
||||
for i=1, 10 do
|
||||
if i % 2 == 0 then
|
||||
continue
|
||||
end
|
||||
print(i) -- 1, 3, 5, 7, 9
|
||||
end
|
||||
```
|
||||
|
||||
Will skip the current loop iteration.
|
||||
|
||||
Compile targets
|
||||
---------------
|
||||
Candran is based on the Lua 5.3 syntax, but can be compiled to both Lua 5.3 and Lua 5.1/LuaJit.
|
||||
|
|
|
|||
|
|
@ -275,6 +275,28 @@ end
|
|||
return a(2, 3)
|
||||
]], 5)
|
||||
|
||||
-- let variable declaration
|
||||
test("let variable declaration", [[
|
||||
let a = {
|
||||
foo = function()
|
||||
return type(a)
|
||||
end
|
||||
}
|
||||
return a.foo()
|
||||
]], "table")
|
||||
|
||||
-- continue keyword
|
||||
test("continue keyword", [[
|
||||
local a = ""
|
||||
for i=1, 10 do
|
||||
if i % 2 == 0 then
|
||||
continue
|
||||
end
|
||||
a = a .. i
|
||||
end
|
||||
return a
|
||||
]], "13579")
|
||||
|
||||
-- results
|
||||
local resultCounter = {}
|
||||
local testCounter = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue