diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-18 01:27:56 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-18 01:28:17 -0700 |
| commit | d5cfaa37be9e278c44a25ef448a071390597306e (patch) | |
| tree | 7fbe78b5153bb9c761c283533943ab80da3a1844 /lib | |
| parent | c7c657d38f999901225b33482ef3a15994526feb (diff) | |
Upgrading to version 2.3 (main change: "=" instead of "<-" for
assignment)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/consolecolor.nom | 7 | ||||
| -rw-r--r-- | lib/file_hash.nom | 10 | ||||
| -rw-r--r-- | lib/object.nom | 20 | ||||
| -rw-r--r-- | lib/os.nom | 9 | ||||
| -rw-r--r-- | lib/training_wheels.nom | 15 | ||||
| -rw-r--r-- | lib/version.nom | 2 |
6 files changed, 26 insertions, 37 deletions
diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index a320b03..39bae68 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -1,11 +1,10 @@ -#!/usr/bin/env nomsu -V2.2.4.3 +#!/usr/bin/env nomsu -V2.3.4.3 # This file defines actions for ANSI console color escape codes. use "core" - test: bright "\(green)Color test passed." -%colors <- {..} +%colors = {..} normal: 0, "reset color": 0, bright: 1, bold: 1, dim: 2, italic: 3, underscore: 4 "slow blink": 5, "fast blink": 6, reverse: 7, inverse: 7, inverted: 7, hidden: 8 # There's some other codes, but they're not currently implemented @@ -20,4 +19,4 @@ for %name = %colornum in %colors: compile [\%name] to: Lua value (quote \(quote %escapecode)) compile [\%name %text] to Lua value ".." - (\\(quote \(quote %escapecode))..\\(%text as lua expr).."\\27[0m") + (\\(quote \(quote %escapecode))..\\(%text as lua expr).."\\27[0m")
\ No newline at end of file diff --git a/lib/file_hash.nom b/lib/file_hash.nom index 542b2f2..283c5b4 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -1,9 +1,8 @@ -#!/usr/bin/env nomsu -V2.2.4.3 +#!/usr/bin/env nomsu -V2.3.4.3 # This file defines some actions for hashing files and looking up files by hash. use "core" - action [file with hash %hash]: lua> ".." local Hash = require("openssl.digest") @@ -19,10 +18,9 @@ action [file with hash %hash]: end action [hash %, sha1 %]: - %hashlib <- (=lua "require('openssl.digest')") - %hash <- (=lua "\%hashlib.new('sha1'):final(\%)") + %hashlib = (=lua "require('openssl.digest')") + %hash = (=lua "\%hashlib.new('sha1'):final(\%)") return (..) =lua "\%hash:gsub('.', function(c) return string.format('%02x', string.byte(c)) end)" -parse [hash of file %filename] as (..) - sha1 (=lua "io.open(\%filename):read('*a')") +parse [hash of file %filename] as (sha1 (=lua "io.open(\%filename):read('*a')"))
\ No newline at end of file diff --git a/lib/object.nom b/lib/object.nom index d41557b..cb5cd3c 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -1,33 +1,29 @@ -#!/usr/bin/env nomsu -V2.2.4.3 +#!/usr/bin/env nomsu -V2.3.4.3 # This file contains the implementation of an Object-Oriented programming system. use "core" - compile [@, me] to (Lua value "self") compile [method %actions %body] to: - %lua <- (compile as (action %actions %body)) + %lua = (compile as (action %actions %body)) add free vars ((% as lua id) for % in %actions) to %lua declare locals in %lua for % in %actions: to %lua write "\nclass.\(% as lua id) = \(% as lua id)" return (..) - Lua ".." - do -- Method: \(%actions.(1).stub) - \%lua - end + Lua "do -- Method: \(%actions.(1).stub)\n \%lua\nend" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ parse [as %instance %body] as (..) result of: - %old_self <- (me) - (me) <- %instance + %old_self = (me) + (me) = %instance try %body and if it barfs %msg: - (me) <- %old_self + (me) = %old_self barf %msg - ..or if it succeeds: (me) <- %old_self + ..or if it succeeds: (me) = %old_self compile [object %classname extends %parent %class_body] to (..) Lua ".." @@ -58,4 +54,4 @@ compile [object %classname extends %parent %class_body] to (..) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ parse [object %classname %class_body] as (..) - object %classname extends (nil) %class_body + object %classname extends (nil) %class_body
\ No newline at end of file @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V2.2.4.3 +#!/usr/bin/env nomsu -V2.3.4.3 # This file defines some actions that interact with the operating system and filesystem. @@ -39,8 +39,5 @@ action [..] ..: lua> "local file = io.open(\%filename, 'w')\nfile:write(\%text)\nfile:close()" -action [line number of %pos in %str] (..) - =lua "files.get_line_number(\%str, \%pos)" - -action [line %line_num in %str] (..) - =lua "files.get_line(\%str, \%line_num)" +action [line number of %pos in %str] (=lua "files.get_line_number(\%str, \%pos)") +action [line %line_num in %str] (=lua "files.get_line(\%str, \%line_num)")
\ No newline at end of file diff --git a/lib/training_wheels.nom b/lib/training_wheels.nom index ea13ac0..4c0b166 100644 --- a/lib/training_wheels.nom +++ b/lib/training_wheels.nom @@ -1,11 +1,10 @@ -#!/usr/bin/env nomsu -V2.2.4.3 +#!/usr/bin/env nomsu -V2.3.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 = %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)) @@ -21,26 +20,26 @@ 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 [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(") + %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)) +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)))" + Lua value "\(%fn as lua expr)(unpack(\(%args as lua expr)))"
\ No newline at end of file diff --git a/lib/version.nom b/lib/version.nom index 24ba7a0..952d940 100644 --- a/lib/version.nom +++ b/lib/version.nom @@ -1,3 +1,3 @@ -#!/usr/bin/env nomsu -V2.2.4.3 +#!/usr/bin/env nomsu -V2.3.4.3 # This file sets the current library version. lua> "NOMSU_LIB_VERSION = 3"
\ No newline at end of file |
