aboutsummaryrefslogtreecommitdiff
path: root/lib/training_wheels.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-17 23:37:20 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-17 23:37:26 -0700
commit88df5c72a317cc011f221627a2c3082078237cc1 (patch)
treea0e983d6aa356dbcd7ec2f71378c3b796e960ac3 /lib/training_wheels.nom
parentaf441330ff7cfdc466281ce135ca7231ec54c499 (diff)
Updating lib to v2
Diffstat (limited to 'lib/training_wheels.nom')
-rw-r--r--lib/training_wheels.nom65
1 files changed, 33 insertions, 32 deletions
diff --git a/lib/training_wheels.nom b/lib/training_wheels.nom
index 970265c..ea13ac0 100644
--- a/lib/training_wheels.nom
+++ b/lib/training_wheels.nom
@@ -1,45 +1,46 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.2.4.3
#
This file contains a set of definitions that bring some familiar language features
from other languages into nomsu (e.g. "==" and "continue")
use "core"
-parse [%a = %b] as: %a <- %b
-parse [%a == %b] as: %a is %b
-parse [%a ~= %b, %a != %b, %a <> %b] as: %a is not %b
-parse [%a === %b] as: (%a's id) is (%b's id)
-parse [%a !== %b] as: (%a's id) is not (%b's id)
-parse [%a mod %b] as: %a wrapped around %b
-parse [function %names %body, def %names %body] as: action %names %body
-parse [switch %branch_value %body] as: when %branch_value = ? %body
-parse [None, Null] as: nil
-parse [True, true] as: yes
-parse [False, false] as: no
-parse [pass] as: do nothing
-parse [%a || %b] as: %a or %b
-parse [%a && %b] as: %a and %b
-parse [continue] as: do next
-parse [break] as: stop
-parse [let %thing = %value in %action] as: with [%thing <- %value] %action
-parse [print %] as: say %
-parse [error!, panic!, fail!, abort!] as: barf!
-parse [error %, panic %, fail %, abort %] as: barf %
-parse [assert %condition %message] as: assume %condition or barf %message
-parse [%cond ? %if_true %if_false] as: %if_true if %cond else %if_false
-compile [function %args %body, lambda %args %body] to
- %lua <-: Lua value "(function("
- for %i = %arg in %args.value
- if: %i > 1
- to %lua write ", "
- to %lua write: %arg as lua expr
+parse [%a = %b] as (%a <- %b)
+parse [%a == %b] as (%a is %b)
+parse [%a ~= %b, %a != %b, %a <> %b] as (%a is not %b)
+parse [%a === %b] as ((%a 's id) is (%b 's id))
+parse [%a !== %b] as ((%a 's id) is not (%b 's id))
+parse [%a mod %b] as (%a wrapped around %b)
+parse [function %names %body, def %names %body] as (action %names %body)
+parse [switch %branch_value %body] as (when %branch_value = ? %body)
+parse [None, Null] as (nil)
+parse [True, true] as (yes)
+parse [False, false] as (no)
+parse [pass] as (do nothing)
+parse [%a || %b] as (%a or %b)
+parse [%a && %b] as (%a and %b)
+parse [continue] as (do next)
+parse [break] as (stop)
+parse [let %thing = %value in %action] as (with [%thing <- %value] %action)
+parse [print %] as (say %)
+parse [error!, panic!, fail!, abort!] as (barf!)
+parse [error %, panic %, fail %, abort %] as (barf %)
+parse [assert %condition %message] as (assume %condition or barf %message)
+parse [%cond ? %if_true %if_false] as (%if_true if %cond else %if_false)
+compile [function %args %body, lambda %args %body] to:
+ %lua <- (Lua value "(function(")
+ for %i = %arg in %args.value:
+ if (%i > 1): to %lua write ", "
+ to %lua write (%arg as lua expr)
+
to %lua write ")\n "
- %body <-: %body as lua
+ %body <- (%body as lua)
lua> "\%body:convert_to_statements('return ');"
for % in %args.value: lua> "\%body:remove_free_vars(\%);"
to %lua write %body
to %lua write "\nend)"
return %lua
-parse [function %name %args %body] as: %name <- (function %args %body)
-compile [call %fn %args] to
+
+parse [function %name %args %body] as (%name <- (function %args %body))
+compile [call %fn %args] to (..)
Lua value "\(%fn as lua expr)(unpack(\(%args as lua expr)))"