diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:02:46 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:02:46 -0800 |
| commit | d8f9b15fd9da8c9ae29ee0b63c4302e5efbde387 (patch) | |
| tree | 418278e778d5bdfcd884e31be612c04c05c2a3dd /core | |
| parent | 0f83a81fa6d2c131aea747da035a53019f3d7d2a (diff) | |
Cleaning up some of the documentation and dead code.
Diffstat (limited to 'core')
| -rw-r--r-- | core/errors.nom | 12 | ||||
| -rw-r--r-- | core/id.nom | 2 | ||||
| -rw-r--r-- | core/math.nom | 50 | ||||
| -rw-r--r-- | core/metaprogramming.nom | 5 |
4 files changed, 3 insertions, 66 deletions
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) |
