From 7131c5c8b1d85049ebe5ac24e984f0a2fee2a155 Mon Sep 17 00:00:00 2001 From: Reuh Date: Wed, 23 Jun 2021 20:54:02 +0200 Subject: [PATCH] Candran 1.0.0 --- README.md | 16 ++++++++-------- candran.can | 2 +- candran.lua | 2 +- ....14.0-1.rockspec => candran-1.0.0-1.rockspec} | 7 ++++--- rockspec/candran-scm-1.rockspec | 3 +-- 5 files changed, 15 insertions(+), 15 deletions(-) rename rockspec/{candran-0.14.0-1.rockspec => candran-1.0.0-1.rockspec} (92%) diff --git a/README.md b/README.md index 78adb83..c708f6b 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,19 @@ Unlike Moonscript, Candran tries to stay close to the Lua syntax, and existing L ````lua #import("lib.thing") -- static import -#local debug = false +#local DEBUG = false -#if debug then -# define("log(...)", "print(...)") +#if DEBUG then +# define("log(...)", "print(...)") -- macro: calls to log() will be replaced with print() in compiled code #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 log("example macro") -- preprocessor macros local function calculate(toadd=25) -- default parameters local result = thing.do() result += toadd - #if debug then -- preprocessor conditionals + #if DEBUG then -- preprocessor conditionals print("Did something") #end return result @@ -83,7 +83,7 @@ Candran is released under the MIT License (see ```LICENSE``` for details). #### Quick setup 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. @@ -449,7 +449,7 @@ Will output ````print("Bonjour")```` or ````print("Hello")```` depending of the The preprocessor has access to the following variables: * ````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`. -* ````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")```) * ```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. @@ -616,7 +616,7 @@ local f = io.open("foo.can") -- read the file foo.can local contents = f:read("*a") 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! diff --git a/candran.can b/candran.can index aee5c57..78a7be4 100644 --- a/candran.can +++ b/candran.can @@ -1,5 +1,5 @@ local candran = { - VERSION = "0.14.0" + VERSION = "1.0.0" } package.loaded["candran"] = candran diff --git a/candran.lua b/candran.lua index 4df71ec..f3945ad 100644 --- a/candran.lua +++ b/candran.lua @@ -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 local function _() -- candran.can:7 local candran = require("candran") -- ./candran/util.can:1 diff --git a/rockspec/candran-0.14.0-1.rockspec b/rockspec/candran-1.0.0-1.rockspec similarity index 92% rename from rockspec/candran-0.14.0-1.rockspec rename to rockspec/candran-1.0.0-1.rockspec index dc82cd2..d291e73 100644 --- a/rockspec/candran-0.14.0-1.rockspec +++ b/rockspec/candran-1.0.0-1.rockspec @@ -2,7 +2,7 @@ rockspec_format = "3.0" package = "candran" -version = "0.14.0-1" +version = "1.0.0-1" description = { summary = "A simple Lua dialect and preprocessor.", @@ -19,14 +19,15 @@ description = { source = { url = "git://github.com/Reuh/candran", - tag = "v0.14.0" + tag = "v1.0.0" } dependencies = { "lua >= 5.1", "lpeglabel >= 1.5.0", "linenoise >= 0.9", - "luacheck >= 0.23.0" + "luacheck >= 0.23.0", + "argparse >= 0.7.0" } build = { diff --git a/rockspec/candran-scm-1.rockspec b/rockspec/candran-scm-1.rockspec index 71ce00b..27d40b5 100644 --- a/rockspec/candran-scm-1.rockspec +++ b/rockspec/candran-scm-1.rockspec @@ -18,8 +18,7 @@ description = { } source = { - url = "git://github.com/Reuh/candran", - branch = "argparse" + url = "git://github.com/Reuh/candran" } dependencies = {