aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/consolecolor.nom19
-rw-r--r--lib/file_hash.nom6
-rw-r--r--lib/object.nom8
-rw-r--r--lib/os.nom8
-rw-r--r--lib/training_wheels.nom9
-rw-r--r--lib/version.nom2
6 files changed, 34 insertions, 18 deletions
diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom
index 6e327ff..bfeaf81 100644
--- a/lib/consolecolor.nom
+++ b/lib/consolecolor.nom
@@ -1,19 +1,22 @@
-#!/usr/bin/env nomsu -V2.4.4.3
+#!/usr/bin/env nomsu -V2.5.4.3
#
This file defines actions for ANSI console color escape codes.
use "core"
-test: bright "\(green)Color test passed."
+
+test:
+ bright "\(green)Color test passed."
+
%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
+ 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
- black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36
- white: 37, "on black": 40, "on red": 41, "on green": 42, "on yellow": 43
- "on blue": 44, "on magenta": 45, "on cyan": 46, "on white": 47
+ black:30, red:31, green:32, yellow:33, blue:34, magenta:35, cyan:36, white:37
+ "on black":40, "on red":41, "on green":42, "on yellow":43, "on blue":44
+ "on magenta":45, "on cyan":46, "on white":47
for %name = %colornum in %colors:
- with {%escapecode: "\27[\(%colornum)m"}:
+ with {%escapecode:"\027[\(%colornum)m"}:
run ".."
#!/usr/bin/env nomsu -V1
compile [\%name] to: Lua value (quote \(quote %escapecode))
diff --git a/lib/file_hash.nom b/lib/file_hash.nom
index 49c768f..7c5668e 100644
--- a/lib/file_hash.nom
+++ b/lib/file_hash.nom
@@ -1,8 +1,9 @@
-#!/usr/bin/env nomsu -V2.4.4.3
+#!/usr/bin/env nomsu -V2.5.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")
@@ -21,6 +22,7 @@ action [hash %, sha1 %]:
%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)"
+ =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')")) \ No newline at end of file
diff --git a/lib/object.nom b/lib/object.nom
index ae52d99..f717cef 100644
--- a/lib/object.nom
+++ b/lib/object.nom
@@ -1,8 +1,9 @@
-#!/usr/bin/env nomsu -V2.4.4.3
+#!/usr/bin/env nomsu -V2.5.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))
@@ -12,7 +13,10 @@ compile [method %actions %body] to:
to %lua write "\nclass.\(% as lua id) = \(% as lua id)"
return (..)
- Lua "do -- Method: \(%actions.(1).stub)\n \%lua\nend"
+ Lua ".."
+ do -- Method: \(%actions.(1).stub)
+ \%lua
+ end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/os.nom b/lib/os.nom
index e29b5d1..a797d2b 100644
--- a/lib/os.nom
+++ b/lib/os.nom
@@ -1,8 +1,9 @@
-#!/usr/bin/env nomsu -V2.4.4.3
+#!/usr/bin/env nomsu -V2.5.4.3
#
This file defines some actions that interact with the operating system and filesystem.
use "core"
+
action [path of Nomsu file %filename]:
lua> "for i,f in files.walk(\%filename) do return f end"
barf "Could not find file: \%filename"
@@ -37,7 +38,10 @@ action [..]
write to file %filename %text, to file %filename write %text
write %text to file %filename
..:
- lua> "local file = io.open(\%filename, 'w')\nfile:write(\%text)\nfile:close()"
+ lua> ".."
+ local file = io.open(\%filename, 'w')
+ file:write(\%text)
+ file: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)") \ No newline at end of file
diff --git a/lib/training_wheels.nom b/lib/training_wheels.nom
index 2845768..100927c 100644
--- a/lib/training_wheels.nom
+++ b/lib/training_wheels.nom
@@ -1,9 +1,10 @@
-#!/usr/bin/env nomsu -V2.4.4.3
+#!/usr/bin/env nomsu -V2.5.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)
@@ -35,11 +36,13 @@ compile [function %args %body, lambda %args %body] to:
to %lua write ")\n "
%body = (%body as lua)
lua> "\%body:convert_to_statements('return ');"
- for % in %args.value: lua> "\%body:remove_free_vars(\%);"
+ 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 (..)
- Lua value "\(%fn as lua expr)(unpack(\(%args as lua expr)))" \ No newline at end of file
+ Lua value "\(%fn as lua expr)(unpack(\(%args as lua expr)))"
diff --git a/lib/version.nom b/lib/version.nom
index 3380301..20ae762 100644
--- a/lib/version.nom
+++ b/lib/version.nom
@@ -1,3 +1,3 @@
-#!/usr/bin/env nomsu -V2.4.4.3
+#!/usr/bin/env nomsu -V2.5.4.3
# This file sets the current library version.
lua> "NOMSU_LIB_VERSION = 3" \ No newline at end of file