aboutsummaryrefslogtreecommitdiff
path: root/nomnom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-09-26 13:05:28 -0700
committerBruce Hill <bruce@bruce-hill.com>2018-09-26 13:05:47 -0700
commitb43432e647fbb3bb76aa2836e3899d5e407c50f9 (patch)
tree640aee09e7dafbcca53c4792d3446c7f6265e004 /nomnom
parent692fae5416ce1f2702b599ffb27b2e3d2235eba7 (diff)
Fixed all syntax errors, got original (non-nomnom) tests passing.
Diffstat (limited to 'nomnom')
-rw-r--r--nomnom/compile.nom2
-rw-r--r--nomnom/decompile.nom21
-rw-r--r--nomnom/files.nom3
-rw-r--r--nomnom/parser.nom4
4 files changed, 14 insertions, 16 deletions
diff --git a/nomnom/compile.nom b/nomnom/compile.nom
index ff3b71f..43e6d84 100644
--- a/nomnom/compile.nom
+++ b/nomnom/compile.nom
@@ -140,7 +140,7 @@ action [compile %tree using %compile_actions]:
..Can't use this as a dict key, since it's not an expression."
%value_lua = (..)
(compile %value using %compile_actions) if %value
- ..else (Lua Value from %key ["true"]))
+ ..else (Lua Value from %key ["true"])
unless %value_lua.is_value:
compile error at %tree.2 "\
..Can't use this as a dict value, since it's not an expression."
diff --git a/nomnom/decompile.nom b/nomnom/decompile.nom
index 27ef406..0d8d4d2 100644
--- a/nomnom/decompile.nom
+++ b/nomnom/decompile.nom
@@ -45,9 +45,10 @@ action [decompile %tree inline]:
"Block":
%nomsu = (Nomsu Code from %tree [":"])
- for i,line in ipairs tree
- %nomsu::add(i == 1 and " " or "; ")
- %nomsu::add recurse(line, nomsu, i == 1 or i < #tree)
+ for %line in %tree at %i:
+ %nomsu::add [..]
+ " " if (%i == 1) else "; "
+ decompile %line inline
return %nomsu
"Text":
@@ -100,12 +101,12 @@ action [decompile %tree inline]:
"IndexChain":
%nomsu = (Nomsu Code from %tree)
for %bit in %tree at %i:
- if (%i > 1): nomsu::add "."
+ if (%i > 1): %nomsu::add "."
if (..)
all of [..]
%i > 1, %bit.type == "Text", (size of %bit) == 1, %bit.1 is text,
%bit.1::is a nomsu identifier
- %nomsu::add %bit.1
+ ..:%nomsu::add %bit.1
..else:
%bit_nomsu = (decompile %bit inline)
if (..)
@@ -261,7 +262,7 @@ action [decompile %tree]:
%bit = (escape text %bit)
for %line in (%bit::lines) at %j:
if:
- (%j > 1): nomsu::add "\n"
+ (%j > 1): %nomsu::add "\n"
(((size of %line) > 10) and ((%nomsu::trailing line length) > %max_line)):
%nomsu::add "\\\n.."
@@ -304,14 +305,14 @@ action [decompile %tree]:
%item_nomsu = (recurse on %item_nomsu)
%nomsu::add %item_nomsu
if (%i < (size of %tree)):
- if (..)
- (%item_nomsu::is multi-line) or (..)
- (%nomsu::trailing line length) + (size of "\%item_nomsu")) >= %MAX_LINE
+ if any of [..]
+ %item_nomsu::is multi-line
+ ((%nomsu::trailing line length) + (size of "\%item_nomsu")) >= %MAX_LINE
..: %nomsu::add "\n"
..else: %nomsu::add ", "
return (..)
Nomsu Code from %tree [..]
- "[..]\n " if tree.type == "List" else "{..}\n "
+ "[..]\n " if (%tree.type == "List") else "{..}\n "
%nomsu
"DictEntry":
diff --git a/nomnom/files.nom b/nomnom/files.nom
index 8fd8f24..a17ec85 100644
--- a/nomnom/files.nom
+++ b/nomnom/files.nom
@@ -82,9 +82,6 @@ try:
..or if it barfs:
# LFS not found! Fall back to shell commands, if available.
unless (sh> "find . -maxdepth 0"):
- url = if jit
- 'https://github.com/spacewander/luafilesystem'
- else
barf "\
..Could not find 'luafilesystem' module and couldn't run system command 'find' \
..(this might happen on Windows). Please install 'luafilesystem' (which can be \
diff --git a/nomnom/parser.nom b/nomnom/parser.nom
index 60c356f..1f460bd 100644
--- a/nomnom/parser.nom
+++ b/nomnom/parser.nom
@@ -21,8 +21,8 @@ set {..}
userdata: Carg 1
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")
+ ..(R "\224\239")*(R "\128\191")*(R "\128\191") +
+ ..(R "\240\244")*(R "\128\191")*(R "\128\191")*(R "\128\191")
Tree: [%t, %userdata] ->:
%source = (..)