summary refs log tree commit diff stats
path: root/luatokens.lua
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2019-04-08 14:48:31 -0300
committerSoniEx2 <endermoneymod@gmail.com>2019-04-08 14:48:31 -0300
commit772e7a9755d1e7b83cfcd3d979e3dcafbbce0078 (patch)
tree4db8615757d21c79fa987676e9ca712156be25b0 /luatokens.lua
parentf56e1bd7e7f9a8d0a55146edba4e7c2ee071487a (diff)
long comments work now
Diffstat (limited to 'luatokens.lua')
-rw-r--r--luatokens.lua52
1 files changed, 24 insertions, 28 deletions
diff --git a/luatokens.lua b/luatokens.lua
index 406fba5..d50f6c1 100644
--- a/luatokens.lua
+++ b/luatokens.lua
@@ -484,38 +484,34 @@ do local tmaybe_comment = setmetatable({["-"] = "comment"}, {__index=defs})
         mknewline(tmcomment, 1, defs)
         mknewline(tmcomment.comment_proper, 1, defs)
         tmcomment.comment_proper[""] = "self"
-        do local tlongcomment = {}
-            tmcomment.longcomment = tlongcomment
-            do local tllongcomment_proper = selfify({[""] = "self", ["]"] = function(state, token) state.longcomment_close = 0 return "maybe_end" end})
-                do local tllmaybe_end = selfify({comment = tcomment}, "maybe_end")
-                    tllongcomment_proper.maybe_end = tllmaybe_end
-                    tllmaybe_end = tllongcomment_proper
-                    tllmaybe_end["="] = function(state, token)
-                        state.longcomment_close = state.longcomment_close + 1
+        do local tllongcomment_proper = selfify({[""] = "self", ["]"] = function(state, token) state.longcomment_close = 0 return "maybe_end" end})
+            tmcomment.longcomment = tllongcomment_proper
+            do local tllmaybe_end = selfify({defs = defs}, "maybe_end")
+                tllongcomment_proper.maybe_end = tllmaybe_end
+                tllmaybe_end.longcomment_proper = tllongcomment_proper
+                tllmaybe_end["="] = function(state, token)
+                    state.longcomment_close = state.longcomment_close + 1
+                    return "maybe_end"
+                end
+                tllmaybe_end["]"] = function(state, token)
+                    if state.longcomment_close == state.longcomment_count then
+                        state.longcomment_close = nil
+                        state.longcomment_count = nil
+                        return "defs"
+                    else
+                        state.longcomment_close = 0
                         return "maybe_end"
                     end
-                    tllmaybe_end["]"] = function(state, token)
-                        if state.longcomment_close == state.longcomment_count then
-                            state.longcomment_close = nil
-                            state.longcomment_count = nil
-                            return "defs"
-                        else
-                            state.longcomment_close = 0
-                            return "maybe_end"
-                        end
-                    end
-                    tllmaybe_end[""] = "longcomment_proper"
-                    tllmaybe_end[-1] = function(state, token, rule)
-                        if not rule then
-                            state.longcomment_close = nil
-                        end
+                end
+                tllmaybe_end[""] = "longcomment_proper"
+                tllmaybe_end[-1] = function(state, token, rule)
+                    if not rule then
+                        state.longcomment_close = nil
                     end
                 end
-
-                tlongcomment.longcomment_proper = tllongcomment_proper
-                mknewline(tlongcomment, 1, tllongcomment_proper)
-                setmetatable(tlongcomment, {__index=tllongcomment_proper})
             end
+
+            mknewline(tllongcomment_proper, 1, tllongcomment_proper)
         end
 
         tmcomment.maybe_longcomment = setmetatable({
@@ -536,7 +532,7 @@ do local tmaybe_comment = setmetatable({["-"] = "comment"}, {__index=defs})
                     return "longcomment_count"
                 elseif token == "[" then
                     state.longcomment_count = 0
-                    return "longstring"
+                    return "longcomment"
                 end
             end,
         }, {__index=tmcomment})