From d8f9b15fd9da8c9ae29ee0b63c4302e5efbde387 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 31 Dec 2018 01:02:46 -0800 Subject: Cleaning up some of the documentation and dead code. --- core/errors.nom | 12 ------------ core/id.nom | 2 +- core/math.nom | 50 ------------------------------------------------ core/metaprogramming.nom | 5 ++--- 4 files changed, 3 insertions(+), 66 deletions(-) (limited to 'core') diff --git a/core/errors.nom b/core/errors.nom index 6a773a7..6779922 100644 --- a/core/errors.nom +++ b/core/errors.nom @@ -88,21 +88,9 @@ test: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# - [..] - try %action and if it succeeds %success or if it barfs %fallback - try %action and if it barfs %fallback or if it succeeds %success - ..all parse as (..) - try %action and if it succeeds %success or if it barfs (=lua "") %fallback - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - (try $action) parses as try $action and if it succeeds (do nothing) or if it barfs (do nothing) -#(try %action and if it barfs %fallback) parses as (..) - try %action and if it succeeds (do nothing) or if it barfs %fallback - (try $action and if it barfs $msg $fallback) parses as try $action and if it succeeds (do nothing) or if it barfs $msg $fallback diff --git a/core/id.nom b/core/id.nom index a22df25..d5f747a 100644 --- a/core/id.nom +++ b/core/id.nom @@ -54,7 +54,7 @@ externally (uuid) means: $bytes.4 += 0xC0 return (=lua "('%08x-%04x-%04x-%02x%02x-%6x%6x'):format(unpack(\$bytes))") -# For strict identity checking, use (%x's id) == (%y's id) +# For strict identity checking, use ($x's id) == ($y's id) test: assume (([] == []) and ((id of []) != (id of []))) seed random with 0 diff --git a/core/math.nom b/core/math.nom index adba0e9..04388cb 100644 --- a/core/math.nom +++ b/core/math.nom @@ -72,38 +72,12 @@ externally [all of $items, all $items] all mean: unless $: return (no) return (yes) - -#[all of %items, all %items] all compile to: - unless (%items.type is "List"): - return \(all of %items) - - if ((size of %items) == 0): - return (Lua "true") - - %lua = (Lua "(") - %lua::add [: for % in %items: add (% as lua expr)] joined with " and " - %lua::add ")" - 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: if $: return (yes) return (no) - -#[any of %items, any %items] all compile to: - unless (%items.type is "List"): - return \(any of %items) - - if ((size of %items) == 0): - return (Lua "false") - - %lua = (Lua "(") - %lua::add [: for % in %items: add (% as lua expr)] joined with " or " - %lua::add ")" - return %lua - [none of $items, none $items] all parse as (not (any of $items)) # Sum/product @@ -113,36 +87,12 @@ externally [sum of $items, sum $items] all mean: $total += $ return $total -#[sum of %items, sum %items] all compile to: - unless (%items.type is "List"): - return \(sum of %items) - - if ((size of %items) == 0): - return (Lua "0") - - %lua = (Lua "(") - %lua::add [: for % in %items: add (% as lua expr)] joined with " + " - %lua::add ")" - return %lua - externally [product of $items, product $items] all mean: $prod = 1 for $ in $items: $prod *= $ return $prod -#[product of %items, product %items] all compile to: - unless (%items.type is "List"): - return \(product of %items) - - if ((size of %items) == 0): - return (Lua "1") - - %lua = (Lua "(") - %lua::add [: for % in %items: add (% as lua expr)] joined with " * " - %lua::add ")" - 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 a9eabd0..2e1bf6b 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -210,11 +210,11 @@ test: [$1, $2] = [1, 2] swap $1 and $2 assume (($1 == 2) and ($2 == 1)) or barf - "'parse % as %' failed on 'swap % and %'" + "'parse $ as $' failed on 'swap $ and $'" [$tmp, $tmp2] = [1, 2] swap $tmp and $tmp2 assume (($tmp == 2) and ($tmp2 == 1)) or barf - "'parse % as %' variable mangling failed." + "'parse $ as $' variable mangling failed." ($actions all parse as $body) compiles to: lua> (" @@ -266,7 +266,6 @@ 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) -- cgit v1.2.3