From c1c32688a4afc43f6addb99b8b5fa878944a70e3 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 14 Jan 2019 15:42:48 -0800 Subject: Overhaul in progress, mostly working. Moved all the nomsu packages into lib/, including core/*. Changes to how nomsu environments and importing work. --- lib/filesystem/init.nom | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lib/filesystem/init.nom (limited to 'lib/filesystem/init.nom') diff --git a/lib/filesystem/init.nom b/lib/filesystem/init.nom new file mode 100644 index 0000000..a228bdc --- /dev/null +++ b/lib/filesystem/init.nom @@ -0,0 +1,36 @@ +#!/usr/bin/env nomsu -V6.14 +# + This file defines some actions that interact with the filesystem. + +externally (files for $path) means: + $files = (=lua "Files.list(\$path)") + if $files: + $files = (List $files) + return $files + +external $(read file $filename) = $Files.read +externally [ + write to file $filename $text, to file $filename write $text + write $text to file $filename +] all mean: + unless ($filename != "stdin"): + fail "Cannot write to stdin" + + 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 + [ + : for $ in ($file, line number at $source.start) to + $file, line number at $source.stop + ..: add ($file, line $) + ], joined with "\n" + +external $(spoof file $text) = $Files.spoof +external $(spoof file $filename = $text) = $Files.spoof -- cgit v1.2.3