aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compatibility/4.10.12.7.nom3
-rw-r--r--core/math.nom37
-rw-r--r--examples/how_do_i.nom2
-rw-r--r--nomsu_decompiler.lua2
-rw-r--r--nomsu_decompiler.moon2
-rwxr-xr-xtools/autoformat.nom10
-rw-r--r--tools/repl.nom4
7 files changed, 12 insertions, 48 deletions
diff --git a/compatibility/4.10.12.7.nom b/compatibility/4.10.12.7.nom
index 982965b..40d6eac 100644
--- a/compatibility/4.10.12.7.nom
+++ b/compatibility/4.10.12.7.nom
@@ -37,6 +37,9 @@ upgrade action (%k = %v for %i in %start to %stop by %step) to "4.10.12.7" as {.
upgrade action (%k = %v for %i in %start to %stop via %step) to "4.10.12.7" as {..}
: for %i in %start to %stop by %step: add %k = %v
+upgrade action (parse %text from %filename) to "4.10.12.7" as (..)
+ (%NomsuCode (%Source %filename 1 (size of %text))) parsed
+
upgrade action (% as lua statements) to "4.10.12.7" as (% as lua)
upgrade action (compile error at %pos %err hint %hint) to "4.10.12.7" as (..)
compile error at %pos %err %hint
diff --git a/core/math.nom b/core/math.nom
index 583cc8c..aa1d200 100644
--- a/core/math.nom
+++ b/core/math.nom
@@ -143,43 +143,6 @@ externally [product of %items, product %items] all mean:
externally [avg of %items, average of %items] all mean (..)
(sum of %items) / (size of %items)
-# Shorthand for control flow
-[if all of %items %body, if all of %items then %body] all parse as (..)
- if (all of %items) %body
-
-[unless all of %items %body, unless all of %items then %body] all parse as (..)
- if (not (all of %items)) %body
-
-[if any of %items %body, if any of %items then %body] all parse as (..)
- if (any of %items) %body
-
-[unless any of %items %body, unless any of %items then %body] all parse as (..)
- if (not (any of %items)) %body
-
-[if none of %items %body, if none of %items then %body] all parse as (..)
- if (not (any of %items)) %body
-
-[unless none of %items %body, unless none of %items then %body] all parse as (..)
- if (any of %items) %body
-
-[if all of %items %body else %else, if all of %items then %body else %else] \
-..all parse as (if (all of %items) %body else %else)
-
-[unless all of %items %body else %else, unless all of %items then %body else %else] \
-..all parse as (if (not (all of %items)) %body else %else)
-
-[if any of %items %body else %else, if any of %items then %body else %else] \
-..all parse as (if (any of %items) %body else %else)
-
-[unless any of %items %body else %else, unless any of %items then %body else %else] \
-..all parse as (if (not (any of %items)) %body else %else)
-
-[if none of %items %body else %else, if none of %items then %body else %else] \
-..all parse as (if (not (any of %items)) %body else %else)
-
-[unless none of %items %body else %else, unless none of %items then %body else %else] \
-..all parse as (if (any of %items) %body else %else)
-
# Min/max
externally [min of %items, smallest of %items, lowest of %items] all mean:
%best = (nil)
diff --git a/examples/how_do_i.nom b/examples/how_do_i.nom
index e26103b..3f816d1 100644
--- a/examples/how_do_i.nom
+++ b/examples/how_do_i.nom
@@ -65,7 +65,7 @@ say "\
Similarly, you can put a long interpolated indented value like: \(..)
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
.. between a backslash and two periods."
-
+
say "Single-line text can contain escape sequences like \", \\, \000, and \n"
# How do I define a list?
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua
index 4655211..4312f6a 100644
--- a/nomsu_decompiler.lua
+++ b/nomsu_decompiler.lua
@@ -242,7 +242,7 @@ tree_to_nomsu = function(tree)
local _exp_0 = tree.type
if "FileChunks" == _exp_0 then
if tree.shebang then
- nomsu:append(tree.shebang, "\n")
+ nomsu:append(tree.shebang)
end
for chunk_no, chunk in ipairs(tree) do
if chunk_no > 1 then
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon
index 5b72823..6053979 100644
--- a/nomsu_decompiler.moon
+++ b/nomsu_decompiler.moon
@@ -184,7 +184,7 @@ tree_to_nomsu = (tree)->
switch tree.type
when "FileChunks"
if tree.shebang
- nomsu\append tree.shebang, "\n"
+ nomsu\append tree.shebang
for chunk_no, chunk in ipairs tree
nomsu\append "\n\n#{("~")\rep(80)}\n\n" if chunk_no > 1
diff --git a/tools/autoformat.nom b/tools/autoformat.nom
index f236ca4..b15f4ce 100755
--- a/tools/autoformat.nom
+++ b/tools/autoformat.nom
@@ -1,7 +1,7 @@
#!/usr/bin/env nomsu -V4.10.12.7
#
Auto-format Nomsu code. Usage:
- nomsu tools/autoformat.nom [-i] file1 file2 directory1 ...
+ nomsu tools/autoformat.nom [-i] file1 file2 directory1 ...
If the first argument is "-i", modifications will be performed in-place. Otherwise,
the formatted code will be printed.
@@ -18,10 +18,10 @@ if (%args.1 is "-i"):
for %path in %args:
for file %filename in %path:
unless (%filename::matches "%.nom$"): do next %filename
- %formatted = "\
- ..#!/usr/bin/env nomsu -V\(Nomsu version)
- \((parse (read file %filename) from %filename) as nomsu)"
-
+ %contents = (read file %filename)
+ %code = (%NomsuCode::from (Source %filename 1 (size of %contents)) %contents)
+ %tree = (%code parsed)
+ %formatted = ((%tree as nomsu)::text)
if %inplace:
write %formatted to file %filename
..else:
diff --git a/tools/repl.nom b/tools/repl.nom
index 9d9e88d..6857df2 100644
--- a/tools/repl.nom
+++ b/tools/repl.nom
@@ -4,9 +4,7 @@ use "lib/os.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-externally [quit, exit] all mean:
- lua> "os.exit(0)"
-
+externally [quit, exit] all mean: lua> "os.exit(0)"
externally (help) means:
say "\
..This is the Nomsu v\(Nomsu version) interactive console.