diff --git a/README.md b/README.md index 1f7439d..b2b489d 100644 --- a/README.md +++ b/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. diff --git a/test/test.lua b/test/test.lua index 7f1b2f0..12a0427 100644 --- a/test/test.lua +++ b/test/test.lua @@ -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