aboutsummaryrefslogtreecommitdiff
path: root/core/errors.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-12-14 20:21:03 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-12-14 20:21:03 -0800
commit4fe63f253f58f87ab986fea38902d95f2a5ea338 (patch)
tree12094f1c69b8ab375eb17507c959c43f9295c6c2 /core/errors.nom
parent6abec65843f0f37f7fc6032ac5db0fff3db71815 (diff)
Auto-updated to version 5
Diffstat (limited to 'core/errors.nom')
-rw-r--r--core/errors.nom76
1 files changed, 38 insertions, 38 deletions
diff --git a/core/errors.nom b/core/errors.nom
index a7e4cff..07b743c 100644
--- a/core/errors.nom
+++ b/core/errors.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.12.8
#
This file contains basic error reporting code
@@ -6,68 +6,68 @@ use "core/metaprogramming.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-(barf %msg) compiles to "\
- ..error(\(=lua "\%msg and \(%msg as lua expr) or 'nil'"), 0);"
+(barf $msg) compiles to \
+.."error(\(=lua "\$msg and \($msg as lua expr) or 'nil'"), 0);"
-(assume %condition) compiles to:
- lua> "local \%assumption = 'Assumption failed: '..tostring((\%condition):get_source_code())"
+(assume $condition) compiles to:
+ lua> "local \$assumption = 'Assumption failed: '..tostring((\$condition):get_source_code())"
return (..)
- Lua "\
- ..if not \(%condition as lua expr) then
- error(\(quote "\%assumption"), 0)
+ Lua "
+ if not \($condition as lua expr) then
+ error(\(quote "\$assumption"), 0)
end"
-(assume %a == %b) compiles to:
- lua> "local \%assumption = 'Assumption failed: '..tostring(\(\(%a == %b) as nomsu))"
+(assume $a == $b) compiles to:
+ lua> "local \$assumption = 'Assumption failed: '..tostring(\(\($a == $b) as nomsu))"
define mangler
return (..)
- Lua "\
- ..do
- local \(mangle "a"), \(mangle "b") = \(%a as lua expr), \(%b as lua expr)
+ Lua "
+ 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"
-(assume %condition or barf %message) compiles to "\
- ..if not \(%condition as lua expr) then
- error(\(%message as lua expr), 0)
+(assume $condition or barf $message) compiles to "
+ if not \($condition as lua expr) then
+ error(\($message as lua expr), 0)
end"
test:
try (barf) and if it succeeds:
barf "try failed."
- %worked = (no)
+ $worked = (no)
try (barf) and if it barfs:
- %worked = (yes)
- assume %worked or barf "try/catch failed"
- %x = 1
+ $worked = (yes)
+ assume $worked or barf "try/catch failed"
+ $x = 1
try:
- %x = 2
- do (barf) then always: %x = 3
+ $x = 2
+ do (barf) then always: $x = 3
..and if it barfs:
do nothing
- assume (%x == 3) or barf "do/then always failed"
+ assume ($x == 3) or barf "do/then always failed"
# Try/except
[..]
- try %action and if it succeeds %success or if it barfs %msg %fallback
- try %action and if it barfs %msg %fallback or if it succeeds %success
-..all compile to "\
- ..do
+ try $action and if it succeeds $success or if it barfs $msg $fallback
+ try $action and if it barfs $msg $fallback or if it succeeds $success
+..all compile to "
+ do
local fell_through = false
local err, erred = nil, false
local ok, ret = xpcall(function()
- \(%action as lua)
+ \($action as lua)
fell_through = true
- end, function(\(=lua "\%fallback and \(%msg as lua expr) or ''"))
+ end, function(\(=lua "\$fallback and \($msg as lua expr) or ''"))
local ok, ret = pcall(function()
- \((=lua "\%fallback or \%msg") as lua)
+ \((=lua "\$fallback or \$msg") as lua)
end)
if not ok then err, erred = ret, true end
end)
if ok then
- \(%success as lua)
+ \($success as lua)
if not fell_through then
return ret
end
@@ -87,14 +87,14 @@ test:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-(try %action) parses as (..)
- try %action and if it succeeds (do nothing) or if it barfs (do nothing)
+(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
+(try $action and if it barfs $msg $fallback) parses as (..)
+ try $action and if it succeeds (do nothing) or if it barfs $msg $fallback
-(try %action and if it succeeds %success) parses as (..)
- try %action and if it succeeds %success or if it barfs (do nothing)
+(try $action and if it succeeds $success) parses as (..)
+ try $action and if it succeeds $success or if it barfs (do nothing)