aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/metaprogramming.nom5
-rw-r--r--nomsu.lua1
-rwxr-xr-xnomsu.moon6
-rw-r--r--nomsu.peg4
4 files changed, 6 insertions, 10 deletions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index 870754b..1b65890 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -155,10 +155,7 @@ action [help %action]:
# Compiler tools
immediately:
compile [run %code] to:
- Lua value ".."
- nomsu:run(\(%code as lua expr), '\
- =lua "nomsu:get_line_number(nomsu.compilestack[#nomsu.compilestack])"
- ..')
+ Lua value "nomsu:run(\(%code as lua expr), \(=lua "tree.source"))"
parse [enable debugging] as: lua> "nomsu.debug = true;"
parse [disable debugging] as: lua> "nomsu.debug = false;"
diff --git a/nomsu.lua b/nomsu.lua
index 70e9fd6..fad9856 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -1149,7 +1149,6 @@ do
end
})
self.use_stack = { }
- self.compilestack = { }
self.file_metadata = setmetatable({ }, {
__mode = "k"
})
diff --git a/nomsu.moon b/nomsu.moon
index 2f04817..3b80aba 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -38,6 +38,7 @@ debug_getinfo = debug.getinfo
-- Add a ((%x foo %y) where {x:"asdf", y:"fdsa"}) compile-time action for substitution
-- Allow plain text backslash like: "\n" in longstrings without requiring "\\n"
-- Maybe support some kind of regex action definitions like "foo %first (and %next)*"?
+-- Re-implement nomsu-to-lua comment translation
export FILE_CACHE
FILE_CACHE = setmetatable {}, {
@@ -181,7 +182,7 @@ NOMSU_PATTERN = do
re.compile(nomsu_peg, NOMSU_DEFS)
class NomsuCompiler
- new:()=>
+ new: =>
-- Weak-key mapping from objects to randomly generated unique IDs
NaN_surrogate = {}
nil_surrogate = {}
@@ -195,7 +196,6 @@ class NomsuCompiler
return id
})
@use_stack = {}
- @compilestack = {}
@file_metadata = setmetatable({}, {__mode:"k"})
@action_metadata = setmetatable({}, {__mode:"k"})
@@ -881,7 +881,7 @@ if arg and debug_getinfo(2).func != require
print "Usage: lua nomsu.lua [-c] [-i] [-p] [-O] [--help] [input [-o output]]"
os.exit!
- nomsu = NomsuCompiler()
+ nomsu = NomsuCompiler!
ok, to_lua = pcall -> require('moonscript.base').to_lua
if not ok then to_lua = nil
diff --git a/nomsu.peg b/nomsu.peg
index 462e03e..bf2c639 100644
--- a/nomsu.peg
+++ b/nomsu.peg
@@ -107,8 +107,8 @@ inline_dict_item:
dict_key:
(({} ({|{%operator / (!number plain_word)}|} -> Tuple) {}) -> Text) / inline_expression
-block_comment(Comment): "#.." { [^%nl]* (%nl+ %indent [^%nl]* (%nl+ %nodent [^%nl]*)* %dedent)? }
-line_comment(Comment): "#" { [^%nl]* }
+block_comment: "#.." [^%nl]* (%nl+ %indent [^%nl]* (%nl+ %nodent [^%nl]*)* %dedent)?
+line_comment: "#" [^%nl]*
eol: %ws* line_comment? (!. / &%nl)
ignored_line: (%nodent (block_comment / line_comment)) / (%ws* (!. / &%nl))