diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-30 19:04:34 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-30 19:04:45 -0800 |
| commit | 8a3c32408733a2f5e14f8a2dbafa3f980b2f73a1 (patch) | |
| tree | 68f1e8a8b956c33ed24cc7a6a369fd97b8849321 /lib/os.nom | |
| parent | 359152da1772ce501609edd8f84b4985ed3e42f2 (diff) | |
Update to new syntax.
Diffstat (limited to 'lib/os.nom')
| -rw-r--r-- | lib/os.nom | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -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) |
