aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/collections.nom2
-rw-r--r--core/control_flow.nom2
-rw-r--r--core/coroutines.nom2
-rw-r--r--core/errors.nom6
-rw-r--r--core/id.nom29
-rw-r--r--core/io.nom2
-rw-r--r--core/math.nom10
-rw-r--r--core/metaprogramming.nom5
-rw-r--r--core/operators.nom2
-rw-r--r--core/scopes.nom2
-rw-r--r--core/text.nom26
11 files changed, 35 insertions, 53 deletions
diff --git a/core/collections.nom b/core/collections.nom
index 2af7605..bc58c7b 100644
--- a/core/collections.nom
+++ b/core/collections.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
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 0c38485..b26b870 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file contains compile-time actions that define basic control flow structures
like "if" statements and loops.
diff --git a/core/coroutines.nom b/core/coroutines.nom
index 753a2ef..d7d1db4 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file defines the code that creates and manipulates coroutines
diff --git a/core/errors.nom b/core/errors.nom
index 638b487..53f88be 100644
--- a/core/errors.nom
+++ b/core/errors.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file contains basic error reporting code
@@ -27,7 +27,9 @@ compile [assume %a == %b] to:
do
local \(mangle "a"), \(mangle "b") = \(%a as lua expr), \(%b as lua expr)
if \(mangle "a") ~= \(mangle "b") then
- error(\(quote "\%assumption").."\\n"..tostring(\(mangle "a")).." != "..tostring(\(mangle "b")), 0)
+ error(\(quote "\%assumption").."\\n"..tostring(\(mangle "a")).." != "..tostring(\(..)
+ mangle "b"
+ ..), 0)
end
end
diff --git a/core/id.nom b/core/id.nom
index 8a213d4..9f41cfb 100644
--- a/core/id.nom
+++ b/core/id.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt
@@ -10,14 +10,16 @@ use "core/control_flow.nom"
%NaN_surrogate = {}
%nil_surrogate = {}
%obj_by_id = {}
-set %obj_by_id's metatable to {__mode: "v"}
+set %obj_by_id's metatable to {__mode:"v"}
%id_by_obj = {}
-set %id_by_obj's metatable to {..}
- __mode: "k"
+set %id_by_obj 's metatable to {..}
+ __mode:"k"
__index: (..)
[%self, %key] ->:
- if (%key == (nil)): return %self.%nil_surrogate
- if (%key != %key): return %self.%NaN_surrogate
+ if (%key == (nil)):
+ return %self.%nil_surrogate
+ if (%key != %key):
+ return %self.%NaN_surrogate
--- %retry ---
%id = (uuid)
if (%obj_by_id.%id != (nil)): go to %retry
@@ -28,16 +30,18 @@ set %id_by_obj's metatable to {..}
action [uuid]:
# Set all the other bits to randomly (or pseudo-randomly) chosen values.
%bytes = [..]
- randint (2^(4*8)), # time-low
- randint (2^(2*8)), # time-mid
- randint (2^(2*8 - 4)), # time-high-and-version
- randint (2^(1*8 - 2)), # clock-seq-and-reserved
- randint (2^(1*8)), # clock-seq-low
- randint (2^(3*8)), randint (2^(3*8)), # node
+ # time-low, time-mid, time-high-and-version
+ randint (2 ^ (4 * 8)), randint (2 ^ (2 * 8)), randint (2 ^ (2 * 8 - 4))
+ # clock-seq-and-reserved, clock-seq-low
+ randint (2 ^ (1 * 8 - 2)), randint (2 ^ (1 * 8)), randint (2 ^ (3 * 8))
+ # node
+ randint (2 ^ (3 * 8))
+
# Set the four most significant bits (bits 12 through 15) of the
# time_hi_and_version field to the 4-bit version number from
# Section 4.1.3.
%bytes.3 += 0x4000
+
# Set the two most significant bits (bits 6 and 7) of the
# clock_seq_hi_and_reserved to zero and one, respectively.
%bytes.4 += 0xC0
@@ -52,5 +56,4 @@ test:
seed random with 0
assume ((id of %x) != (id of []))
seed random
-
action [id of %, %'s id, %' id] %id_by_obj.%
diff --git a/core/io.nom b/core/io.nom
index e47554f..d656419 100644
--- a/core/io.nom
+++ b/core/io.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file contains basic input/output code
diff --git a/core/math.nom b/core/math.nom
index 6a205b6..439b698 100644
--- a/core/math.nom
+++ b/core/math.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file defines some common math literals and functions
@@ -73,27 +73,27 @@ compile [all of %items, all %items] to:
unless (%items.type is "List"):
return (Lua value "utils.all(\(%items as lua expr))")
%clauses = ((% as lua expr) for % in %items)
- return (Lua value "(\(%clauses joined with " and "))")
+ return (Lua value "(\(%clauses::joined with " and "))")
parse [not all of %items, not all %items] as (not (all of %items))
compile [any of %items, any %items] to:
unless (%items.type is "List"):
return (Lua value "utils.any(\(%items as lua expr))")
%clauses = ((% as lua expr) for % in %items)
- return (Lua value "(\(%clauses joined with " or "))")
+ return (Lua value "(\(%clauses::joined with " or "))")
parse [none of %items, none %items] as (not (any of %items))
compile [sum of %items, sum %items] to:
unless (%items.type is "List"):
return (Lua value "utils.sum(\(%items as lua expr))")
%clauses = ((% as lua expr) for % in %items)
- return (Lua value "(\(%clauses joined with " + "))")
+ return (Lua value "(\(%clauses::joined with " + "))")
compile [product of %items, product %items] to:
unless (%items.type is "List"):
return (Lua value "utils.product(\(%items as lua expr))")
%clauses = ((% as lua expr) for % in %items)
- return (Lua value "(\(%clauses joined with " * "))")
+ return (Lua value "(\(%clauses::joined with " * "))")
action [avg of %items, average of %items] (=lua "(utils.sum(\%items)/#\%items)")
compile [min of %items, smallest of %items, lowest of %items] to (..)
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index c978bf8..836b5a2 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -1,9 +1,9 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This File contains actions for making actions and compile-time actions and some helper
functions to make that easier.
-lua> "NOMSU_CORE_VERSION = 7"
+lua> "NOMSU_CORE_VERSION = 8"
lua> ".."
do
local mangle_index = 0
@@ -18,6 +18,7 @@ lua> ".."
COMPILE_ACTIONS["define mangler"] = function(nomsu, tree)
return LuaCode(tree.source, "local mangle_1 = mangler()")
end
+
lua> ".."
COMPILE_ACTIONS["1 -> 2"] = function(nomsu, tree, \%args, \%body)
local lua = LuaCode.Value(tree.source, "(function(")
diff --git a/core/operators.nom b/core/operators.nom
index 9395d9d..3d18275 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file contains definitions of operators like "+" and "and".
diff --git a/core/scopes.nom b/core/scopes.nom
index 6ee2939..6cc79c0 100644
--- a/core/scopes.nom
+++ b/core/scopes.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file contains definitions pertaining to variable scoping
diff --git a/core/text.nom b/core/text.nom
index bd9335a..da9d550 100644
--- a/core/text.nom
+++ b/core/text.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.7.5.6
+#!/usr/bin/env nomsu -V3.8.7.6
#
This file contains some definitions of text escape sequences, including ANSI console
color codes.
@@ -26,36 +26,12 @@ test:
assume ("asdf"::uppercase) == "ASDF"
assume ("asdf"::with "s" -> "X") == "aXdf"
assume ("one\ntwo\n"::lines) == ["one", "two", ""]
-
parse [アクション %spec %body] as (action %spec %body)
test:
%こんにちは = "こんにちは"
アクション [% と言う] "\(%)世界"
assume (%こんにちは と言う) == "こんにちは世界"
-# Text functions
-parse [%texts joined with %glue] as (%texts::joined with %glue)
-parse [%texts joined, joined %texts] as (%texts::joined)
-parse [byte %i of %text] as (%text::byte %i)
-parse [bytes %start to %stop of %text] as (%text::bytes %start to %stop)
-parse [bytes of %text] as (%text::bytes)
-parse [capitalized %text, %text capitalized] as (%text::capitalized)
-parse [uppercase %text, %text uppercase] as (%text::uppercase)
-parse [..]
- %text with %sub instead of %patt, %text with %patt replaced by %sub
- %text s/ %patt / %sub
-..as (%text::with %patt -> %sub)
-parse [%text matches %pattern] as (%text::matches %pattern)
-parse [%text matching %pattern] as ((%text::matching %pattern).1)
-
-compile [for %match in %text matching %patt %body] to (..)
- Lua ".."
- for \(%match as lua expr) in (\(%text as lua expr)):gmatch(\(%patt as lua expr)) do
- \(%body as lua statements)
- \(compile as (===next %match ===))
- end
- \(compile as (===stop %match ===))
-
compile [%expr for %match in %text matching %patt] to (..)
Lua value ".."
(function()