diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-14 15:42:48 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-14 15:43:24 -0800 |
| commit | c1c32688a4afc43f6addb99b8b5fa878944a70e3 (patch) | |
| tree | c886f21b5b08a9053aa74fcba4b241dae5ede76d /tools/format.nom | |
| parent | 2309b696fc34b24f05f6658b94f9105ca8ee76e4 (diff) | |
Overhaul in progress, mostly working. Moved all the nomsu packages into
lib/, including core/*. Changes to how nomsu environments and importing
work.
Diffstat (limited to 'tools/format.nom')
| -rwxr-xr-x | tools/format.nom | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/tools/format.nom b/tools/format.nom deleted file mode 100755 index 07f7980..0000000 --- a/tools/format.nom +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env nomsu -V6.14 -# - Auto-format Nomsu code. Usage: - nomsu -t format [-i] file1 file2... - - If the "-i" flag is used, the file will be edited in-place. - If the "-q" flag is used and an error occurs, the original file will be printed. - If no files are passed in, this will read from stdin. - -use "lib/os" - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -$filenames = $(COMMAND LINE ARGS).extras -if ((#$filenames) == 0): - say (" - Warning: reading from stdin (ctrl-d to abort). To avoid this message, use nomsu -t format - - ") - $filenames = ["stdin"] - -for $filename in $filenames: - $file = (read file $filename) - unless $file: - fail "File does not exist: \$filename" - $leading_indent = ($file, matching "\n*([ ]*)") - $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file) - try: - $tree = ($code parsed) - ..if it fails $msg: - if $(COMMAND LINE ARGS).q: - $formatted = $file - ..else: - say $msg - - if ($tree and (not $formatted)): - $formatted = - "\$leading_indent\($tree as nomsu, text, with "\n" -> "\n\$leading_indent")" - - if $formatted: - if $(COMMAND LINE ARGS).i: - write $formatted to file $filename - ..else: - say $formatted inline |
