code / nomsu

Lines6.6K Lua5.1K PEG1.3K make117
2 others 83
Markdown60 Bourne Again Shell23
(38 lines)
1 #!/usr/bin/env nomsu -V7.0.0
2 ###
3 This file defines some actions that interact with the filesystem.
5 external:
6 (files for $path) means:
7 $files = (=lua "Files.list(\$path)")
8 if $files:
9 $files = (List $files)
10 return $files
11 $(read file $filename) = $Files.read
13 write to file $filename $text, to file $filename write $text
14 write $text to file $filename
15 ] all mean:
16 unless ($filename != "stdin"):
17 fail "Cannot write to stdin"
19 lua> ("
20 local file = io.open(\$filename, 'w')
21 file:write(\$text)
22 file:close()
23 ")
25 (source lines of $tree) means:
26 $source = ($tree.source if ($tree is syntax tree) else $tree)
27 $file = (read file $source.filename)
28 return
29 [:
30 for $ in
31 ($file, line number at $source.start) to ($file, line number at $source.stop)
32 ..:
33 add ($file, line $)
34 ], joined with "\n"
36 $(spoof file $text) = $Files.spoof
37 $(spoof file $filename = $text) = $Files.spoof
38 $(make directory $path) = $Files.make_directory