diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/os.nom | 39 | ||||
| -rw-r--r-- | lib/training_wheels.nom | 27 |
2 files changed, 13 insertions, 53 deletions
@@ -3,11 +3,17 @@ This file defines some actions that interact with the operating system and filesystem. test: - path of Nomsu file "lib/os.nom" + assume (nomsu files for "core") -externally (path of Nomsu file %filename) means: - lua> "for i,f in Files.walk(\%filename) do return f end" - barf "Could not find file: \%filename" +externally (files for %path) means: + %files = (=lua "Files.list(\%path)") + if %files: %files = (List %files) + return %files + +externally (nomsu files for %path) means: + for %nomsupath in (%package.nomsupath::all matches of "[^;]+"): + %files = (files for "\%nomsupath/\%path") + if %files: return %files externally (sh> %cmd) means: lua> "\ @@ -23,14 +29,10 @@ externally (read file %filename) means (=lua "Files.read(\%filename)") test: for file %f in "core": do nothing -(for file %f in %path %body) compiles to "\ - ..for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do - \(%body as lua) - \(what (===next %f ===) compiles to) - end - \(what (===stop %f ===) compiles to)" +(for file %f in %path %body) parses as (for %f in (nomsu files for %path) %body) -(%expr for file %f in %path) compiles to "\ +# TODO: deprecate +#(%expr for file %f in %path) compiles to "\ ..(function() local ret = List{} for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do @@ -49,21 +51,6 @@ externally [..] file:write(\%text) file:close()" -test: - assume (line number of 3 in "x\ny") == 2 - -externally (line number of %pos in %str) means (..) - =lua "Files.get_line_number(\%str, \%pos)" - -test: - assume (line 2 in "one\ntwo\nthree") == "two" - -externally (line %line_num in %str) means (..) - =lua "Files.get_line(\%str, \%line_num)" - -test: - assume (source lines of \(this)) - externally (source lines of %tree) means: %source = (%tree.source if (%tree is syntax tree) else %tree) %file = (read file %source.filename) diff --git a/lib/training_wheels.nom b/lib/training_wheels.nom deleted file mode 100644 index 00ad64b..0000000 --- a/lib/training_wheels.nom +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env nomsu -V4.10.12.7 -# - This file contains a set of definitions that bring some familiar language features - from other languages into nomsu (e.g. "||" and "continue") - -(%a === %b) parses as ((%a's id) is (%b's id)) -(%a !== %b) parses as ((%a's id) is not (%b's id)) -[function %names %body, def %names %body] all parse as (..) - externally %names means %body -(switch %branch_value %body) parses as (if %branch_value is %body) -[None, Null] all parse as (nil) -[True, true] all parse as (yes) -[False, false] all parse as (no) -(pass) parses as (do nothing) -(%a || %b) parses as (%a or %b) -(%a && %b) parses as (%a and %b) -(continue) parses as (do next) -(break) parses as (stop) -(let %thing = %value in %action) parses as (with local {%thing: %value}) -[print %, println %] all parse as (say %) -[error!, panic!, fail!, abort!] all parse as (barf!) -[error %, panic %, fail %, abort %] all parse as (barf %) -(assert %condition) parses as (assume %condition) -(assert %condition %message) parses as (assume %condition or barf %message) -(%cond ? %if_true %if_false) parses as (%if_true if %cond else %if_false) -(lambda %args %body) parses as (%args -> %body) -(function %name %args %body) parses as (%name = (%args -> %body)) |
