From 8a3c32408733a2f5e14f8a2dbafa3f980b2f73a1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 30 Dec 2018 19:04:34 -0800 Subject: Update to new syntax. --- lib/os.nom | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'lib/os.nom') diff --git a/lib/os.nom b/lib/os.nom index b5f95e8..cdb5398 100644 --- a/lib/os.nom +++ b/lib/os.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines some actions that interact with the operating system and filesystem. @@ -12,39 +12,44 @@ externally (files for $path) means: return $files externally (nomsu files for $path) means: - for $nomsupath in ($package.nomsupath|all matches of "[^;]+"): + for $nomsupath in ($package.nomsupath, all matches of "[^;]+"): $files = (files for "\($nomsupath)/\$path") if $files: return $files externally (sh> $cmd) means: - lua> " + lua> (" local result = io.popen(\$cmd) local contents = result:read("*a") result:close() - return contents" + return contents + ") test: read file "lib/os.nom" externally (read file $filename) means (=lua "Files.read(\$filename)") -externally [..] +externally [ write to file $filename $text, to file $filename write $text write $text to file $filename -..all mean: +] all mean: assume ($filename != "stdin") or barf "Cannot write to stdin" - lua> "local file = io.open(\$filename, 'w')\nfile:write(\$text)\nfile:close()" + lua> (" + local file = io.open(\$filename, 'w') + file:write(\$text) + file:close() + ") externally (source lines of $tree) means: $source = ($tree.source if ($tree is syntax tree) else $tree) $file = (read file $source.filename) - return (..) - [..] + return + [ : - for $ in ($file|line number at $source.start) to (..) - $file|line number at $source.stop - ..: add ($file|line $) - ..|joined with "\n" + for $ in ($file, line number at $source.start) to + $file, line number at $source.stop + ..: add ($file, line $) + ], joined with "\n" externally (spoof file $text) means ($Files.spoof $text) externally (spoof file $filename = $text) means ($Files.spoof $filename $text) -- cgit v1.2.3