aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-19 17:37:37 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-19 17:37:37 -0800
commita89d69e843ba83df928051005d02a932a9981f46 (patch)
tree17f99cda2d4e5f0a7983ed14f4ac559b64944207 /core
parent43ff3892f39188163446f1a00ee8d2aad59e0392 (diff)
Autoformatted/auto-upgraded.
Diffstat (limited to 'core')
-rw-r--r--core/collections.nom2
-rw-r--r--core/control_flow.nom4
-rw-r--r--core/coroutines.nom16
-rw-r--r--core/errors.nom2
-rw-r--r--core/id.nom2
-rw-r--r--core/io.nom2
-rw-r--r--core/math.nom26
-rw-r--r--core/metaprogramming.nom12
-rw-r--r--core/operators.nom6
-rw-r--r--core/text.nom3
10 files changed, 36 insertions, 39 deletions
diff --git a/core/collections.nom b/core/collections.nom
index a586882..9272d13 100644
--- a/core/collections.nom
+++ b/core/collections.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains code that supports manipulating and using collections like lists
and dictionaries.
diff --git a/core/control_flow.nom b/core/control_flow.nom
index 9432a92..27ff96d 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains compile-time actions that define basic control flow structures
like "if" statements and loops.
@@ -54,7 +54,7 @@ test:
..all compile to:
# If %when_true_expr is guaranteed to be truthy, we can use Lua's idiomatic
equivalent of a conditional expression: (cond and if_true or if_false)
- if {"Text", "List", "Dict", "Number"}.(%when_true_expr.type):
+ if {Text, List, Dict, Number}.(%when_true_expr.type):
return (Lua "(\(%condition as lua expr) and \(%when_true_expr as lua expr) or \(%when_false_expr as lua expr))")
..else:
# Otherwise, need to do an anonymous inline function (yuck, too bad lua
diff --git a/core/coroutines.nom b/core/coroutines.nom
index 0a625c2..73b6854 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines the code that creates and manipulates coroutines
@@ -13,16 +13,13 @@ test:
->:
yield 4
yield 5
- repeat 3 times: yield 6
-
+ repeat 3 times:
+ yield 6
%nums = []
for % in coroutine %co:
%nums::add %
-
assume (%nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
-
-
- %d = {x:0}
+ %d = {x: 0}
%co2 = (..)
coroutine:
%d.x += 1
@@ -30,12 +27,9 @@ test:
%d.x += 1
yield
%d.x += 1
- repeat while ((coroutine status of %co2) != "dead"):
- resume %co2
+ repeat while ((coroutine status of %co2) != "dead"): resume %co2
assume %d.x == 3
-
(coroutine %body) parses as (coroutine from (-> %body))
-
(for % in coroutine %co %body) compiles to "\
..for \(% as lua expr) in coroutine_wrap(\(%co as lua expr)) do
\(%body as lua)
diff --git a/core/errors.nom b/core/errors.nom
index 12a5b29..aa5346b 100644
--- a/core/errors.nom
+++ b/core/errors.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains basic error reporting code
diff --git a/core/id.nom b/core/id.nom
index 7de38f9..9ee961d 100644
--- a/core/id.nom
+++ b/core/id.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt
diff --git a/core/io.nom b/core/io.nom
index c667466..04efb91 100644
--- a/core/io.nom
+++ b/core/io.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains basic input/output code
diff --git a/core/math.nom b/core/math.nom
index 38fb984..ae01620 100644
--- a/core/math.nom
+++ b/core/math.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines some common math literals and functions
@@ -72,16 +72,16 @@ externally [all of %items, all %items] all mean:
#[all of %items, all %items] all compile to:
unless (%items.type is "List"):
- return \(all of %items)
+ return \(all of %items)
if ((size of %items) == 0):
- return (Lua "true")
+ return (Lua "true")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " and "
%lua::append ")"
return %lua
-
+
[not all of %items, not all %items] all parse as (not (all of %items))
externally [any of %items, any %items] all mean:
for % in %items:
@@ -91,16 +91,16 @@ externally [any of %items, any %items] all mean:
#[any of %items, any %items] all compile to:
unless (%items.type is "List"):
- return \(any of %items)
+ return \(any of %items)
if ((size of %items) == 0):
- return (Lua "false")
+ return (Lua "false")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " or "
%lua::append ")"
return %lua
-
+
[none of %items, none %items] all parse as (not (any of %items))
# Sum/product
@@ -112,16 +112,16 @@ externally [sum of %items, sum %items] all mean:
#[sum of %items, sum %items] all compile to:
unless (%items.type is "List"):
- return \(sum of %items)
+ return \(sum of %items)
if ((size of %items) == 0):
- return (Lua "0")
+ return (Lua "0")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " + "
%lua::append ")"
return %lua
-
+
externally [product of %items, product %items] all mean:
%prod = 1
for % in %items:
@@ -130,16 +130,16 @@ externally [product of %items, product %items] all mean:
#[product of %items, product %items] all compile to:
unless (%items.type is "List"):
- return \(product of %items)
+ return \(product of %items)
if ((size of %items) == 0):
- return (Lua "1")
+ return (Lua "1")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " * "
%lua::append ")"
return %lua
-
+
externally [avg of %items, average of %items] all mean (..)
(sum of %items) / (size of %items)
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index fe97527..c89b1df 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This File contains actions for making actions and compile-time actions and some helper
functions to make that easier.
@@ -253,16 +253,16 @@ test:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[%action parses as %body] all parse as ([%action] all parse as %body)
+
#(%tree as lua expr) compiles to "compile(\(=lua "compile(\%tree, true)"), true)"
externally (%tree as lua expr) means:
lua> "\
..local tree_lua = compile(\%tree)
if \%tree.type == 'Block' then
- tree_lua = LuaCode:from(\%tree.source, '(function()\n ', tree_lua, '\nend)()')
+ tree_lua = LuaCode:from(\%tree.source, '(function()\\n ', tree_lua, '\\nend)()')
end
return tree_lua"
-
externally [%var as lua identifier, %var as lua id] all mean:
lua> "\
..if lua_type_of(\%var) == 'string' then return \%var:as_lua_id()
@@ -283,8 +283,8 @@ test:
assume (extra args 1 2 3) == [1, 2, 3]
(third arg (*extra arguments*)) means (select 3 (*extra arguments*))
assume (third arg 5 6 7 8) == 7
-(*extra arguments*) compiles to "..."
+(*extra arguments*) compiles to "..."
(% is syntax tree) compiles to "SyntaxTree:is_instance(\(% as lua expr))"
externally (% is %kind syntax tree) means (..)
=lua "SyntaxTree:is_instance(\%) and \%.type == \%kind"
@@ -394,8 +394,10 @@ test:
..compile(\(%block as lua))"
test:
- (foo) means: return 100 200 300
+ (foo) means:
+ return 100 200 300
assume (select 2 (foo)) == 200
+
# Return statement is wrapped in a do..end block because Lua is unhappy if you
put code after a return statement, unless you wrap it in a block.
(return (*extra arguments*)) compiles to:
diff --git a/core/operators.nom b/core/operators.nom
index 2f79b8f..1a28a6a 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains definitions of operators like "+" and "and".
@@ -51,7 +51,8 @@ test:
if #\%value ~= #\%var then
compile_error_at(\%value,
"This assignment has too "..(#\%value > #\%var and "many" or "few").." values.",
- "Make sure it has the same number of values on the left and right hand side of the '=' operator.")
+ "Make sure it has the same number of values on the left and right hand side of the '\
+ ..=' operator.")
end
for i, \%val in ipairs(\%value) do
if i > 1 then lua:append(", ") end
@@ -149,7 +150,6 @@ test:
assume (0 <= (one) <= 2) or barf "Three-way chained comparison failed."
assume (%calls == 1) or barf "\
..Three-way comparison evaluated middle value multiple times"
-
(%x < %y < %z) parses as (((%a %b %c) -> ((%a < %b) and (%b < %c))) %x %y %z)
(%x <= %y < %z) parses as (((%a %b %c) -> ((%a <= %b) and (%b < %c))) %x %y %z)
(%x < %y <= %z) parses as (((%a %b %c) -> ((%a < %b) and (%b <= %c))) %x %y %z)
diff --git a/core/text.nom b/core/text.nom
index 62b6656..1245235 100644
--- a/core/text.nom
+++ b/core/text.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains some definitions of text escape sequences, including ANSI console
color codes.
@@ -50,6 +50,7 @@ test:
test:
assume (0xDEADBEEF as hex) == "0xDEADBEEF"
+
externally (%num as hex) means:
if (%num < 0):
return ("-0x%X"::formatted with (- %num))