aboutsummaryrefslogtreecommitdiff
path: root/lib/os.nom
diff options
context:
space:
mode:
Diffstat (limited to 'lib/os.nom')
-rw-r--r--lib/os.nom30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/os.nom b/lib/os.nom
index 2c9addf..e6faa18 100644
--- a/lib/os.nom
+++ b/lib/os.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.8.7.6
+#!/usr/bin/env nomsu -V4.8.8.6
#
This file defines some actions that interact with the operating system and filesystem.
@@ -9,11 +9,11 @@ action [path of Nomsu file %filename]:
barf "Could not find file: \%filename"
action [sh> %cmd]:
- lua> ".."
- local result = io.popen(\%cmd)
+ lua> "\
+ ..local result = io.popen(\%cmd)
local contents = result:read("*a")
result:close()
- return contents
+ return contents"
test:
read file "lib/os.nom"
@@ -22,39 +22,39 @@ action [read file %filename] (=lua "Files.read(\%filename)")
test:
for file %f in "core": do nothing
compile [for file %f in %path %body] to (..)
- Lua ".."
- for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do
+ Lua "\
+ ..for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do
\(%body as lua statements)
\(compile as (===next %f ===))
end
- \(compile as (===stop %f ===))
+ \(compile as (===stop %f ===))"
compile [%expr for file %f in %path] to (..)
- Lua value ".."
- (function()
+ Lua value "\
+ ..(function()
local ret = _List{}
for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do
ret[#ret+1] = \(%expr as lua statements)
end
return ret
- end)()
+ end)()"
action [..]
write to file %filename %text, to file %filename write %text
write %text to file %filename
..:
assume (%filename != "stdin") or barf "Cannot write to stdin"
- lua> ".."
- local file = io.open(\%filename, 'w')
+ lua> "\
+ ..local file = io.open(\%filename, 'w')
file:write(\%text)
- file:close()
+ file:close()"
test:
- assume ((line number of 3 in "x\ny") == 2)
+ assume (line number of 3 in "x\ny") == 2
action [line number of %pos in %str] (=lua "Files.get_line_number(\%str, \%pos)")
test:
- assume ((line 2 in "one\ntwo\nthree") == "two")
+ assume (line 2 in "one\ntwo\nthree") == "two"
action [line %line_num in %str] (=lua "Files.get_line(\%str, \%line_num)")
test: