diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-14 20:21:03 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-14 20:21:03 -0800 |
| commit | 4fe63f253f58f87ab986fea38902d95f2a5ea338 (patch) | |
| tree | 12094f1c69b8ab375eb17507c959c43f9295c6c2 /tools/autoformat.nom | |
| parent | 6abec65843f0f37f7fc6032ac5db0fff3db71815 (diff) | |
Auto-updated to version 5
Diffstat (limited to 'tools/autoformat.nom')
| -rwxr-xr-x | tools/autoformat.nom | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/tools/autoformat.nom b/tools/autoformat.nom index 44d91e3..76d1d27 100755 --- a/tools/autoformat.nom +++ b/tools/autoformat.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.12.12.8 +#!/usr/bin/env nomsu -V5.12.12.8 # Auto-format Nomsu code. Usage: nomsu tools/autoformat.nom [-i] file1 file2 directory1 ... @@ -9,18 +9,18 @@ use "lib/os.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -%args = (command line args) -for %filename in %args.extra_args: - %file = (read file %filename) - unless %file: - barf "File does not exist: \%filename" - %leading_indent = (%file::matching "[\n]*([ ]*)") - %code = (NomsuCode from (%Source %filename 1 (size of %file)) %file) - %tree = (%code parsed) - %formatted = "\ - ..\%leading_indent\(((%tree as nomsu)::text)::with "\n" -> "\n\%leading_indent")" +$args = (command line args) +for $filename in $args.extra_args: + $file = (read file $filename) + unless $file: + barf "File does not exist: \$filename" + $leading_indent = ($file|matching "[\n]*([ ]*)") + $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file) + $tree = ($code parsed) + $formatted = " + \$leading_indent\((($tree as nomsu)|text)|with "\n" -> "\n\$leading_indent")" - if %args."-i": - write %formatted to file %filename + if $args."-i": + write $formatted to file $filename ..else: - say %formatted inline + say $formatted inline |
