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:
parent
5fff7612f4
commit
dc19ac56a9
13 changed files with 2007 additions and 2000 deletions
2
bin/can
2
bin/can
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/lua
|
||||
local candran = require("candran")
|
||||
local cmdline = require("lib.cmdline")
|
||||
local cmdline = require("candran.cmdline")
|
||||
|
||||
local args = cmdline(arg)
|
||||
|
||||
|
|
|
|||
6
bin/canc
6
bin/canc
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/lua
|
||||
local candran = require("candran")
|
||||
local cmdline = require("lib.cmdline")
|
||||
local parse = require("lib.lua-parser.parser").parse
|
||||
local pp = require("lib.lua-parser.pp")
|
||||
local cmdline = require("candran.cmdline")
|
||||
local parse = require("candran.can-parser.parser").parse
|
||||
local pp = require("candran.can-parser.pp")
|
||||
|
||||
local args = cmdline(arg)
|
||||
|
||||
|
|
|
|||
12
candran.can
12
candran.can
|
|
@ -1,14 +1,14 @@
|
|||
#import("lib.util")
|
||||
#import("lib.cmdline")
|
||||
#import("candran.util")
|
||||
#import("candran.cmdline")
|
||||
|
||||
#import("compiler.lua53")
|
||||
#import("compiler.luajit")
|
||||
#import("compiler.lua51")
|
||||
|
||||
#import("lib.lua-parser.scope")
|
||||
#import("lib.lua-parser.validator")
|
||||
#import("lib.lua-parser.pp")
|
||||
#import("lib.lua-parser.parser")
|
||||
#import("candran.can-parser.scope")
|
||||
#import("candran.can-parser.validator")
|
||||
#import("candran.can-parser.pp")
|
||||
#import("candran.can-parser.parser")
|
||||
|
||||
local candran = {
|
||||
VERSION = "0.11.0"
|
||||
|
|
|
|||
3973
candran.lua
3973
candran.lua
File diff suppressed because it is too large
Load diff
|
|
@ -9,7 +9,7 @@ block: { stat* }
|
|||
stat:
|
||||
`Do{ stat* }
|
||||
| `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
|
||||
| `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
|
||||
|
|
@ -452,6 +452,10 @@ local function maybeBlockWithEnd () -- same as above but don't error if it doesn
|
|||
+ Cmt(V"BlockNoErr", searchEnd)
|
||||
end
|
||||
|
||||
local function maybe (patt) -- fail pattern instead of propagating errors
|
||||
return #patt/0 * patt
|
||||
end
|
||||
|
||||
local stacks = {
|
||||
lexpr = {}
|
||||
}
|
||||
|
|
@ -577,7 +581,7 @@ local G = { V"Lua",
|
|||
+ tagC("Boolean", kw("true") * Cc(true))
|
||||
+ tagC("Dots", sym("..."))
|
||||
+ 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"SuffixedExpr"
|
||||
+ V"StatExpr";
|
||||
|
|
@ -722,7 +726,7 @@ local G = { V"Lua",
|
|||
|
||||
local parser = {}
|
||||
|
||||
local validator = require("lib.lua-parser.validator")
|
||||
local validator = require("candran.can-parser.validator")
|
||||
local validate = validator.validate
|
||||
local syntaxerror = validator.syntaxerror
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
--[[
|
||||
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 new_scope, end_scope = scope.new_scope, scope.end_scope
|
||||
|
|
@ -2,7 +2,7 @@ local candran = dofile(arg[1] or "../candran.lua")
|
|||
candran.default.indentation = "\t"
|
||||
candran.default.mapLines = false
|
||||
|
||||
local load = require("lib.util").load
|
||||
local load = require("candran.util").load
|
||||
|
||||
-- test helper
|
||||
local results = {} -- tests result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue