mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 09:59:29 +00:00
Candran 1.0.0
This commit is contained in:
parent
f0cacd6f08
commit
7131c5c8b1
5 changed files with 15 additions and 15 deletions
16
README.md
16
README.md
|
|
@ -6,19 +6,19 @@ Unlike Moonscript, Candran tries to stay close to the Lua syntax, and existing L
|
||||||
|
|
||||||
````lua
|
````lua
|
||||||
#import("lib.thing") -- static import
|
#import("lib.thing") -- static import
|
||||||
#local debug = false
|
#local DEBUG = false
|
||||||
|
|
||||||
#if debug then
|
#if DEBUG then
|
||||||
# define("log(...)", "print(...)")
|
# define("log(...)", "print(...)") -- macro: calls to log() will be replaced with print() in compiled code
|
||||||
#else
|
#else
|
||||||
# define("log(...)", "") -- remove calls to log from the compiled code when debug is true
|
# define("log(...)", "") -- remove calls to log from the compiled code when DEBUG is true
|
||||||
#end
|
#end
|
||||||
log("example macro") -- preprocessor macros
|
log("example macro") -- preprocessor macros
|
||||||
|
|
||||||
local function calculate(toadd=25) -- default parameters
|
local function calculate(toadd=25) -- default parameters
|
||||||
local result = thing.do()
|
local result = thing.do()
|
||||||
result += toadd
|
result += toadd
|
||||||
#if debug then -- preprocessor conditionals
|
#if DEBUG then -- preprocessor conditionals
|
||||||
print("Did something")
|
print("Did something")
|
||||||
#end
|
#end
|
||||||
return result
|
return result
|
||||||
|
|
@ -83,7 +83,7 @@ Candran is released under the MIT License (see ```LICENSE``` for details).
|
||||||
#### Quick setup
|
#### Quick setup
|
||||||
Install Candran automatically using LuaRocks: ```sudo luarocks install candran```.
|
Install Candran automatically using LuaRocks: ```sudo luarocks install candran```.
|
||||||
|
|
||||||
Or manually install LPegLabel (```luarocks install lpeglabel```, version 1.5 or above), download this repository and use Candran through the scripts in ```bin/``` or use it as a library with the self-contained ```candran.lua```.
|
Or manually install LPegLabel and argparse (```luarocks install lpeglabel```, version 1.5 or above, and ```luarocks install argparse```, version 0.7 or above), download this repository and use Candran through the scripts in ```bin/``` or use it as a library with the self-contained ```candran.lua```.
|
||||||
|
|
||||||
You can optionally install lua-linenoise (```luarocks install linenoise```, version 0.9 or above) for an improved REPL, and luacheck (```luarocks install luacheck```, version 0.23.0 or above) to be able to use ```cancheck```. Installing Candran using LuaRocks will install linenoise and luacheck by default.
|
You can optionally install lua-linenoise (```luarocks install linenoise```, version 0.9 or above) for an improved REPL, and luacheck (```luarocks install luacheck```, version 0.23.0 or above) to be able to use ```cancheck```. Installing Candran using LuaRocks will install linenoise and luacheck by default.
|
||||||
|
|
||||||
|
|
@ -449,7 +449,7 @@ Will output ````print("Bonjour")```` or ````print("Hello")```` depending of the
|
||||||
The preprocessor has access to the following variables:
|
The preprocessor has access to the following variables:
|
||||||
* ````candran````: the Candran library table.
|
* ````candran````: the Candran library table.
|
||||||
* ````output````: the current preprocessor output string. Can be redefined at any time. If you want to write something in the preprocessor output, it is preferred to use `write(...)` instead of directly modifying `output`.
|
* ````output````: the current preprocessor output string. Can be redefined at any time. If you want to write something in the preprocessor output, it is preferred to use `write(...)` instead of directly modifying `output`.
|
||||||
* ````import(module[, [options])````: a function which import a module. This should be equivalent to using _require(module)_ in the Candran code, except the module will be embedded in the current file. _options_ is an optional preprocessor arguments table for the imported module (current preprocessor arguments will be inherited). Options specific to this function:
|
* ````import(module[, [options])````: a function which import a module. This should be equivalent to using _require(module)_ in the Candran code, except the module will be embedded in the current file. Macros and preprocessor constants defined in the imported file (using `define` and `set`) will be made available in the current file. _options_ is an optional preprocessor arguments table for the imported module (current preprocessor arguments will be inherited). Options specific to this function:
|
||||||
* ```loadLocal``` (default ```true```): ```true``` to automatically load the module into a local variable (i.e. ```local thing = require("module.thing")```)
|
* ```loadLocal``` (default ```true```): ```true``` to automatically load the module into a local variable (i.e. ```local thing = require("module.thing")```)
|
||||||
* ```loadPackage``` (default ```true```): ```true``` to automatically load the module into the loaded packages table (so it will be available for following ```require("module")``` calls).
|
* ```loadPackage``` (default ```true```): ```true``` to automatically load the module into the loaded packages table (so it will be available for following ```require("module")``` calls).
|
||||||
* ````include(filename)````: a function which copy the contents of the file _filename_ to the output.
|
* ````include(filename)````: a function which copy the contents of the file _filename_ to the output.
|
||||||
|
|
@ -616,7 +616,7 @@ local f = io.open("foo.can") -- read the file foo.can
|
||||||
local contents = f:read("*a")
|
local contents = f:read("*a")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
local compiled = candran.make(contents, { debug = true }) -- compile foo.can with debug set to true
|
local compiled = candran.make(contents, { DEBUG = true }) -- compile foo.can with DEBUG set to true
|
||||||
|
|
||||||
load(compiled)() -- execute!
|
load(compiled)() -- execute!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local candran = {
|
local candran = {
|
||||||
VERSION = "0.14.0"
|
VERSION = "1.0.0"
|
||||||
}
|
}
|
||||||
package.loaded["candran"] = candran
|
package.loaded["candran"] = candran
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local candran = { ["VERSION"] = "0.14.0" } -- candran.can:2
|
local candran = { ["VERSION"] = "1.0.0" } -- candran.can:2
|
||||||
package["loaded"]["candran"] = candran -- candran.can:4
|
package["loaded"]["candran"] = candran -- candran.can:4
|
||||||
local function _() -- candran.can:7
|
local function _() -- candran.can:7
|
||||||
local candran = require("candran") -- ./candran/util.can:1
|
local candran = require("candran") -- ./candran/util.can:1
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ rockspec_format = "3.0"
|
||||||
|
|
||||||
package = "candran"
|
package = "candran"
|
||||||
|
|
||||||
version = "0.14.0-1"
|
version = "1.0.0-1"
|
||||||
|
|
||||||
description = {
|
description = {
|
||||||
summary = "A simple Lua dialect and preprocessor.",
|
summary = "A simple Lua dialect and preprocessor.",
|
||||||
|
|
@ -19,14 +19,15 @@ description = {
|
||||||
|
|
||||||
source = {
|
source = {
|
||||||
url = "git://github.com/Reuh/candran",
|
url = "git://github.com/Reuh/candran",
|
||||||
tag = "v0.14.0"
|
tag = "v1.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"lua >= 5.1",
|
"lua >= 5.1",
|
||||||
"lpeglabel >= 1.5.0",
|
"lpeglabel >= 1.5.0",
|
||||||
"linenoise >= 0.9",
|
"linenoise >= 0.9",
|
||||||
"luacheck >= 0.23.0"
|
"luacheck >= 0.23.0",
|
||||||
|
"argparse >= 0.7.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
build = {
|
build = {
|
||||||
|
|
@ -18,8 +18,7 @@ description = {
|
||||||
}
|
}
|
||||||
|
|
||||||
source = {
|
source = {
|
||||||
url = "git://github.com/Reuh/candran",
|
url = "git://github.com/Reuh/candran"
|
||||||
branch = "argparse"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue