1
0
Fork 0
mirror of https://github.com/Reuh/candran.git synced 2025-10-27 09:59:29 +00:00

Rename lib to candran

This commit is contained in:
Étienne Fildadut 2020-01-19 15:36:25 +01:00
parent 5fff7612f4
commit dc19ac56a9
13 changed files with 2007 additions and 2000 deletions

View file

@ -1,6 +1,6 @@
#!/bin/lua #!/bin/lua
local candran = require("candran") local candran = require("candran")
local cmdline = require("lib.cmdline") local cmdline = require("candran.cmdline")
local args = cmdline(arg) local args = cmdline(arg)

View file

@ -1,8 +1,8 @@
#!/bin/lua #!/bin/lua
local candran = require("candran") local candran = require("candran")
local cmdline = require("lib.cmdline") local cmdline = require("candran.cmdline")
local parse = require("lib.lua-parser.parser").parse local parse = require("candran.can-parser.parser").parse
local pp = require("lib.lua-parser.pp") local pp = require("candran.can-parser.pp")
local args = cmdline(arg) local args = cmdline(arg)

View file

@ -1,14 +1,14 @@
#import("lib.util") #import("candran.util")
#import("lib.cmdline") #import("candran.cmdline")
#import("compiler.lua53") #import("compiler.lua53")
#import("compiler.luajit") #import("compiler.luajit")
#import("compiler.lua51") #import("compiler.lua51")
#import("lib.lua-parser.scope") #import("candran.can-parser.scope")
#import("lib.lua-parser.validator") #import("candran.can-parser.validator")
#import("lib.lua-parser.pp") #import("candran.can-parser.pp")
#import("lib.lua-parser.parser") #import("candran.can-parser.parser")
local candran = { local candran = {
VERSION = "0.11.0" VERSION = "0.11.0"

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@ block: { stat* }
stat: stat:
`Do{ stat* } `Do{ stat* }
| `Set{ {lhs+} (opid? = opid?)? {expr+} } -- lhs1, lhs2... op=op e1, e2... | `Set{ {lhs+} (opid? = opid?)? {expr+} } -- lhs1, lhs2... op=op e1, e2...
| `While{ expr block } -- while e do b end | `While{ lexpr block } -- while e do b end
| `Repeat{ block expr } -- repeat b until e | `Repeat{ block expr } -- repeat b until e
| `If{ (lexpr block)+ block? } -- if e1 then b1 [elseif e2 then b2] ... [else bn] end | `If{ (lexpr block)+ block? } -- if e1 then b1 [elseif e2 then b2] ... [else bn] end
| `Fornum{ ident expr expr expr? block } -- for ident = e, e[, e] do b end | `Fornum{ ident expr expr expr? block } -- for ident = e, e[, e] do b end
@ -452,6 +452,10 @@ local function maybeBlockWithEnd () -- same as above but don't error if it doesn
+ Cmt(V"BlockNoErr", searchEnd) + Cmt(V"BlockNoErr", searchEnd)
end end
local function maybe (patt) -- fail pattern instead of propagating errors
return #patt/0 * patt
end
local stacks = { local stacks = {
lexpr = {} lexpr = {}
} }
@ -577,7 +581,7 @@ local G = { V"Lua",
+ tagC("Boolean", kw("true") * Cc(true)) + tagC("Boolean", kw("true") * Cc(true))
+ tagC("Dots", sym("...")) + tagC("Dots", sym("..."))
+ V"FuncDef" + V"FuncDef"
+ (when("lexpr") * tagC("LetExpr", V"DestructuringNameList" * sym("=") * -sym("=") * expect(V"ExprList", "EListLAssign"))) + (when("lexpr") * tagC("LetExpr", maybe(V"DestructuringNameList") * sym("=") * -sym("=") * expect(V"ExprList", "EListLAssign")))
+ V"ShortFuncDef" + V"ShortFuncDef"
+ V"SuffixedExpr" + V"SuffixedExpr"
+ V"StatExpr"; + V"StatExpr";
@ -722,7 +726,7 @@ local G = { V"Lua",
local parser = {} local parser = {}
local validator = require("lib.lua-parser.validator") local validator = require("candran.can-parser.validator")
local validate = validator.validate local validate = validator.validate
local syntaxerror = validator.syntaxerror local syntaxerror = validator.syntaxerror

View file

@ -1,7 +1,7 @@
--[[ --[[
This module impements a validator for the AST This module impements a validator for the AST
]] ]]
local scope = require "lib.lua-parser.scope" local scope = require "candran.can-parser.scope"
local lineno = scope.lineno local lineno = scope.lineno
local new_scope, end_scope = scope.new_scope, scope.end_scope local new_scope, end_scope = scope.new_scope, scope.end_scope

View file

@ -2,7 +2,7 @@ local candran = dofile(arg[1] or "../candran.lua")
candran.default.indentation = "\t" candran.default.indentation = "\t"
candran.default.mapLines = false candran.default.mapLines = false
local load = require("lib.util").load local load = require("candran.util").load
-- test helper -- test helper
local results = {} -- tests result local results = {} -- tests result