From b6d3cbd61cd08e39d20a569b7c5ece6bb25897dd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 1 Jan 2019 15:05:58 -0800 Subject: Misc changes, including text indented interpolations are now indented relative to the text, not the opening '("', code objects can now remove all free vars, the REPL uses global vars. Error API is changing a bit. --- parser.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'parser.lua') diff --git a/parser.lua b/parser.lua index 523e223..09386fa 100644 --- a/parser.lua +++ b/parser.lua @@ -26,6 +26,13 @@ do _with_0.unpack = unpack or table.unpack _with_0["nil"] = Cc(nil) _with_0.userdata = Carg(1) + _with_0.indentation = lpeg.Cmt(P(0), function(s, i) + local sub = string.sub + while i > 1 and sub(s, i - 1, i - 1) ~= '\n' do + i = i - 1 + end + return true, (s:match("^ *", i)) + end) _with_0.utf8_char = (R("\194\223") * R("\128\191") + R("\224\239") * R("\128\191") * R("\128\191") + R("\240\244") * R("\128\191") * R("\128\191") * R("\128\191")) _with_0.Tree = function(t, userdata) return userdata.make_tree(t, userdata) -- cgit v1.2.3