application/octet-stream
•
16.32 KB
•
150 lines
#{##["Nujel Standalone" test-context file/eval [path environment] #@[documentation: "Evaluate a Nujel source file in the current context" source: ["Evaluate a Nujel source file in the current context" [when-not environment [set! environment root-closure]] [eval-in environment [cons 'do [read [file/read path]]]]]] #{##[environment root-closure eval-in do read file/read path]
1A00050B0007240900091A01051A00080D1A02051A00051A031A04051A05051A
06050401040114040201
} file/compile [path environment] #@[documentation: "Compile a Nujel source file into optimized object code" source: ["Compile a Nujel source file into optimized object code" [def source [cons 'do [read [file/read path]]]] [def object-code [compile* source [or environment [environment*]]]] [file/write [if object-code [string/write object-code] ""] [cat [path/without-extension path] ".no"]] [return object-code]]] #{##[do read file/read path source compile* environment #f object-code file/write string/write "" cat path/without-extension ".no"]
1A001A01051A02051A030504010401141A04070D1A05051A04051A06050C0A00
100D15240D13160C0A00060D1A0704021A08070D1A09051A08050B000E1A0A05
1A080504010900051A0B1A0C051A0D051A030504011A0E040204020D1A080501
01
} file/compile/module [path environment base-dir] #@[documentation: "Compile a Nujel source file into optimized object code" source: ["Compile a Nujel source file into optimized object code" [def module-name [string->keyword [path/without-extension [string/cut path [length base-dir]]]]] [def source [quasiquote [defmodule [unquote module-name] [def *module* [unquote module-name]] [unquote-splicing [read [file/read path]]]]]] [def object-code [compile* source [or environment [environment*]]]] [file/write [if object-code [string/write object-code] ""] [cat [path/without-extension path] ".no"]] [return object-code]]] #{##[symbol->keyword string->symbol path/without-extension string/cut path length base-dir module-name defmodule def *module* append read file/read source compile* environment #f object-code file/write string/write "" cat ".no"]
1A00051A01051A02051A03051A04051A05051A0605040104020401040104011A
07070D1A081A07051A091A0A1A0705241414141A0B051A0C051A0D051A040504
0104012404021414141A0E070D1A0F051A0E051A10050C0A00100D15240D1316
0C0A00060D1A1104021A12070D1A13051A12050B000E1A14051A120504010900
051A151A16051A02051A040504011A17040204020D1A12050101
} file/compile/argv [] #@[source: [[def path [car [last-pair repl/args]]] [def module [index-of path "_modules/"]] [if [>= module 0] [file/compile/module path #nil [string/cut path 0 [+ module 9]]] [file/compile path]]]] #{##[last-pair repl/args path index-of "_modules/" module file/compile/module string/cut file/compile]
1A00051A01050401111A02070D1A03051A02051A0404021A05070D1A05050200
210B001F1A06051A0205241A07051A020502001A05050209250403040309000B
1A08051A0205040101
} file/test/module/run [tests module-name] #@[source: [[require :test] [doseq [expr tests] [test/run-test! [eval [cadr expr]] [quasiquote [do [require [unquote module-name]] [unquote-splicing [cddr expr]]]]]]]] #{##[require* :test current-closure #t tests ΓεnΣym-1 expr test/run-test! eval-in do require module-name append]
1A00051A011A020504001A0304030D151A04051A05070D1A05050B004C240900
3F0D1A0505111A06070D1A07051A08051A020504001A0605121104021A091A0A
1A0B052414141A0C051A06051212240402141404020D1A0505121A05081A0505
0AFFC1090004241601
} valid-test-form? [form] #@[source: [[== [car form] 'deftest]]] #{##[form deftest]
1A0005111A012001
} file/test/module [path base-dir] #@[documentation: "Test a module by running all contained tests" source: ["Test a module by running all contained tests" [def rel-path [string/cut path [length base-dir]]] [when [== [char-at rel-path 0] 47] [set! rel-path [string/cut rel-path 1]]] [def module-name [string->keyword [path/without-extension rel-path]]] [require :test] [test/init!] [-> [read [file/read path]] [filter valid-test-form?] [file/test/module/run module-name]] [test/finish! [ansi-blue module-name]]]] #{##[string/cut path length base-dir rel-path char-at symbol->keyword string->symbol path/without-extension module-name require* :test current-closure #t test/init! file/test/module/run filter read file/read valid-test-form? test/finish! ansi-blue]
1A00051A01051A02051A0305040104021A04070D1A05051A040502000402022F
200B00131A00051A0405020104021A0408090004240D1A06051A07051A08051A
04050401040104011A09070D1A0A051A0B1A0C0504001A0D04030D1A0E050400
0D1A0F051A10051A11051A12051A0105040104011A130504021A090504020D1A
14051A15051A09050401040101
} file/test/directory [base-dir] #@[documentation: "Compile a Nujel source file into optimized object code" source: ["Compile a Nujel source file into optimized object code" [-> [directory/read-recursive base-dir] [flatten] [sort] [filter [path/ext?! "nuj"]] [map [fn [path] [file/test/module path base-dir]]] [sum]]]] #{##[sum map filter sort flatten directory/read-recursive base-dir path/ext?! "nuj" anonymous [path] #@[source: [[file/test/module path base-dir]]] #{##[file/test/module path base-dir]
1A00051A01051A0205040201
}]
1A00051A01051A02051A03051A04051A05051A06050401040104011A07051A08
040104021A091A0A1A0B1A0C170402040101
} load [filename] #@[source: [[try [fn [err] [display/error err] #f] [file/eval filename] [pfmtln "Loaded {filename}"] #t]]] #{##[anonymous [err] #@[source: [[display/error err] #f]] #{##[display/error err #f]
1A00051A010504010D1A0201
} file/eval filename println cat "Loaded " #t]
1A001A011A021A031719001F1A04051A050504010D1A06051A07051A081A0505
040204010D1A091601
} file/file? [filename] #@[source: [[ref [file/stat filename] :regular-file?]]] #{##[ref file/stat filename :regular-file?]
1A00051A01051A020504011A03040201
} file/dir? [filename] #@[source: [[ref [file/stat filename] :directory?]]] #{##[ref file/stat filename :directory?]
1A00051A01051A020504011A03040201
} directory/read-relative [path] #@[source: [[map [directory/read path] [fn [a] [cat path "/" a]]]]] #{##[map directory/read path anonymous [a] #@[source: [[cat path "/" a]]] #{##[cat path "/" a]
1A00051A01051A021A0305040301
}]
1A00051A01051A020504011A031A041A051A0617040201
} directory/read-recursive [path] #@[source: [[flatten [map [directory/read-relative path] [fn [A] [if [file/dir? A] [directory/read-recursive A] A]]]]]] #{##[flatten map directory/read-relative path anonymous [A] #@[source: [[if [file/dir? A] [directory/read-recursive A] A]]] #{##[file/dir? A directory/read-recursive]
1A00051A010504010B000E1A02051A010504010900061A010501
}]
1A00051A01051A02051A030504011A041A051A061A07170402040101
} popen/trim [cmd] #@[documentation: "Run CMD using popen and return the trimmed stdout" source: ["Run CMD using popen and return the trimmed stdout" [trim [cdr [popen cmd]]]]] #{##[trim popen cmd]
1A00051A01051A0205040112040101
} path/working-directory +root-working-dir+ file/module-loader [name] #@[source: [[def module-path [fmt "{+root-working-dir+}/modules/{}.nuj" [keyword->string name]]] [def source [file/read module-path]] [when-not source [return #nil]] [def expr [list 'module [cons do [read source]]]] [def mod [eval expr]] [return mod]]] #{##[keyword->string name fmt-arg-0 cat +root-working-dir+ "/modules/" ".nuj" module-path file/read source list module do read expr eval-in current-closure mod]
151A00051A010504011A02070D1A03051A04051A051A02051A060404161A0707
0D1A08051A070504011A09070D1A09050B00072409000524010D1A0A051A0B1A
0C051A0D051A090504011404021A0E070D1A0F051A100504001A0E0504021A11
070D1A11050101
} module/add-loader]
1A001A01070D1A021A031A041A05171A02070D1A061A071A081A09171A06070D
1A0A1A0B1A0C1A0D171A0A070D1A0E1A0F1A101A11171A0E070D1A121A131A14
1A15171A12070D1A161A171A181A19171A16070D1A1A1A1B1A1C1A1D171A1A07
0D1A1E1A1F1A201A21171A1E070D1A221A231A241A25171A22070D1A261A271A
281A29171A26070D1A2A1A2B1A2C1A2D171A2A070D1A2E1A2F1A301A31171A2E
070D1A321A331A341A35171A32070D1A361A371A381A39171A36070D1A3A0504
001A3B070D1A3C1A3D1A3E1A3F171A3C070D1A40051A3C05040101
}#{##[*1 *2 *3 "nujel" repl/executable-name repl/args #f repl/parse-args/eval-next #t repl/parse-args/run-repl tree/new repl/options repl/option-map repl/exception-handler [error] #@[source: [[display/error error]]] #{##[display/error error]
1A00051A0105040101
} repl/welcome [] #@[source: [[println [cat [ansi-rainbow "Nujel"] " is ready for business!"]]]] #{##[println cat ansi-rainbow "Nujel" " is ready for business!"]
1A00051A01051A02051A0304011A040402040101
} repl/prompt [] #@[documentation: ">" source: ["> "]] #{##["> "]
1A0001
} repl/wasm [line] #@[documentation: "Evaluate LINE in the wasm context" source: ["Evaluate LINE in the wasm context" [try repl/exception-handler [eval-in root-closure [cons do [read line]]]]]] #{##[repl/exception-handler eval-in root-closure do read line]
1A00051900181A01051A02051A03051A04051A050504011404021601
} repl/cmd/raw [ctx line] #@[source: [[try [fn [err] [if [= [car err] :unmatched-opening-bracket] [repl/cmd/raw ctx [cat line [readline "... "]]] [throw err]]] [def expr [read line]] [when [equal? '[] expr] [print "\r"] [return]] [def result [eval-in ctx [cons do expr]]] [repl/push-result result] [println [if [nil? result] "" [string result]]]]]] #{##[anonymous [err] #@[source: [[if [= [car err] :unmatched-opening-bracket] [repl/cmd/raw ctx [cat line [readline "... "]]] [throw err]]]] #{##[err :unmatched-opening-bracket repl/cmd/raw ctx cat line readline "... " throw]
1A0005111A01200B001D1A02051A03051A04051A05051A06051A070401040204
0209000B1A08051A0005040101
} read line expr equal? [] print "\r" eval-in ctx do result repl/push-result println nil? "" string]
1A001A011A021A03171900651A04051A050504011A06070D1A07051A081A0605
04020B00101A09051A0A04010D2401090004240D1A0B051A0C051A0D051A0605
1404021A0E070D1A0F051A0E0504010D1A10051A11051A0E0504010B00081A12
09000B1A13051A0E05040104011601
} repl/push-result [result] #@[source: [[set! *3 *2] [set! *2 *1] [set! *1 result] [return result]]] #{##[*2 *3 *1 result]
1A00051A01080D1A02051A00080D1A03051A02080D1A03050101
} repl/cmd [ctx] #@[source: [[def buf ""] [def line ""] [while [not= line "[/cmd]\n"] [set! buf [cat buf line]] [set! line [readline]]] [def expr [cons do [read buf]]] [def result [eval-in ctx expr]] [repl/push-result result] [println [if [nil? result] "" [string result]]]]] #{##["" buf line cat readline not= "[/cmd]\n" do read expr eval-in ctx result repl/push-result println nil? string]
1A001A01070D1A001A02070D2409001B0D1A03051A01051A020504021A01080D
1A040504001A02081A05051A02051A0604020AFFDE0D1A07051A08051A010504
01141A09070D1A0A051A0B051A090504021A0C070D1A0D051A0C0504010D1A0E
051A0F051A0C0504010B00081A0009000B1A10051A0C050401040101
} repl/readline [ctx] #@[source: [[def line [readline [repl/prompt]]] [when [nil? line] [display "Adios, cowboy...\r\n"] [exit 0]] [if [= line "[cmd]\n"] [repl/cmd ctx] [repl/cmd/raw ctx line]]]] #{##[readline repl/prompt line nil? print "Adios, cowboy...\r\n" exit "[cmd]\n" repl/cmd ctx repl/cmd/raw]
1A00051A0105040004011A02070D1A03051A020504010B00151A04051A050401
0D1A060502000401090004240D1A02051A07200B000E1A08051A090504010900
0E1A0A051A09051A0205040201
} repl [] #@[source: [[repl/welcome] [while #t [try repl/exception-handler [repl/readline root-closure]]]]] #{##[repl/welcome repl/exception-handler repl/readline root-closure #t]
1A000504000D240900130D1A010519000C1A02051A03050401161A040AFFEE01
} repl/print-help [] #@[source: [[println [cat [ansi-rainbow "Nujel"] " - A Lisp dialect for games.\n"]] [println [cat [ansi-green "Usage:"] " nujel [options] [command_string | file]"]] [println [cat "\nLow-level options - for work on the runtime itself"]] [println [cat " " [ansi-yellow "v"] " - be verbose"]] [println [cat "\nHigh-level options - for working with/on Nujel code"]] [println [cat " " [ansi-blue "x"] " - Run the expression following this argument directly"]] [println [cat " " [ansi-blue "h"] " - Print this help screen"]] [println [cat "\nLong options - for working with/on Nujel code"]] [println [cat " " [ansi-blue "no-color"] " - Disable ANSI color"]] [println [cat " " [ansi-blue "color "] " - Enable ANSI color"]]]] #{##[println cat ansi-rainbow "Nujel" " - A Lisp dialect for games.\n" ansi-green "Usage:" " nujel [options] [command_string | file]" "\nLow-level options - for work on the runtime itself" " " ansi-yellow "v" " - be verbose" "\nHigh-level options - for working with/on Nujel code" ansi-blue "x" " - Run the expression following this argument directly" "h" " - Print this help screen" "\nLong options - for working with/on Nujel code" "no-color" " - Disable ANSI color" "color " " - Enable ANSI color"]
1A00051A01051A02051A0304011A04040204010D1A00051A01051A05051A0604
011A07040204010D1A00051A01051A08040104010D1A00051A01051A091A0A05
1A0B04011A0C040304010D1A00051A01051A0D040104010D1A00051A01051A09
1A0E051A0F04011A10040304010D1A00051A01051A091A0E051A1104011A1204
0304010D1A00051A01051A13040104010D1A00051A01051A091A0E051A140401
1A15040304010D1A00051A01051A091A0E051A1604011A170403040101
} tree/set! h anonymous [option] #@[source: [[repl/print-help] [set! repl/parse-args/run-repl #f]]] #{##[repl/print-help #f repl/parse-args/run-repl]
1A000504000D1A011A020801
} no-color [option] #@[source: [[set! ansi/disabled ""]]] #{##["" ansi/disabled]
1A001A010801
} color [option] #@[source: [[set! ansi/disabled #f]]] #{##[#f ansi/disabled]
1A001A010801
} x [option] #@[source: [[set! repl/parse-args/eval-next #t] [set! repl/parse-args/run-repl #f]]] #{##[#t repl/parse-args/eval-next #f repl/parse-args/run-repl]
1A001A01080D1A021A030801
} :default [option] #@[source: [[tree/set! repl/options option #t]]] #{##[tree/set! repl/options option #t]
1A00051A01051A02051A03040301
} repl/parse-option [option] #@[source: [[[or [ref repl/option-map option] [ref repl/option-map :default]] option]]] #{##[ref repl/option-map option :default #f]
1A00051A01051A020504020C0A00150D1A00051A01051A0304020C0A00060D1A
041A0205040101
} repl/parse-options [options] #@[source: [[if [= [char-at options 0] 45] [repl/parse-option [string->keyword [cut options 1]]] [for-each [map [split options ""] string->symbol] repl/parse-option]]]] #{##[char-at options repl/parse-option symbol->keyword string->symbol cut for-each map split ""]
1A00051A010502000402022D200B001F1A02051A03051A04051A05051A010502
01040204010401040109001D1A06051A07051A08051A01051A0904021A040504
021A0205040201
} repl/parse-arg [arg] #@[source: [[cond [repl/parse-args/eval-next [try display/error [eval-in root-closure [cons do [read arg]]] [set! repl/parse-args/eval-next #f]]] [[= [char-at arg 0] 45] [repl/parse-options [string/cut arg 1]]] [#t [try display/error [file/eval arg]] [set! repl/parse-args/run-repl #f]]]]] #{##[repl/parse-args/eval-next display/error eval-in root-closure do read arg #f char-at repl/parse-options string/cut #t file/eval repl/parse-args/run-repl]
1A00050B00271A010519001E1A02051A03051A04051A05051A06050401140402
0D1A071A0008160900431A08051A060502000402022D200B00151A09051A0A05
1A06050201040204010900211A0B0B001B1A010519000C1A0C051A0605040116
0D1A071A0D080900042401
} repl/parse-args [args] #@[source: [[if args [do [repl/parse-arg [car args]] [repl/parse-args [cdr args]]] repl/parse-args/run-repl]]] #{##[args repl/parse-arg repl/parse-args repl/parse-args/run-repl]
1A00050B00191A01051A00051104010D1A02051A00051204010900061A030501
} repl/init/wasm [args] #@[source: [[repl/welcome]]] #{##[repl/welcome]
1A0005040001
} repl/init/bin [args] #@[source: [[try repl/exception-handler [set! repl/executable-name [car args]] [when [repl/parse-args [cdr args]] [repl]]]]] #{##[repl/exception-handler args repl/executable-name repl/parse-args repl]
1A00051900211A0105111A02080D1A03051A01051204010B000B1A0405040009
0004241601
} repl/init args #@[source: [[set! repl/args args] [if [= System/Architecture 'wasm] [repl/init/wasm args] [repl/init/bin args]]]] #{##[args repl/args System/Architecture wasm repl/init/wasm repl/init/bin]
1A00051A01080D1A02051A03200B000E1A04051A0005040109000B1A05051A00
05040101
}]
241A00070D241A01070D241A02070D1A031A04070D241A05070D1A061A07070D
1A081A09070D1A0A052404011A0B070D1A0A052404011A0C070D1A0D1A0E1A0F
1A10171A0D070D1A111A121A131A14171A11070D1A151A161A171A18171A1507
0D1A191A1A1A1B1A1C171A19070D1A1D1A1E1A1F1A20171A1D070D1A211A221A
231A24171A21070D1A251A261A271A28171A25070D1A291A2A1A2B1A2C171A29
070D1A2D1A2E1A2F1A30171A2D070D1A311A321A331A34171A31070D1A35051A
0C051A361A371A381A391A3A1704030D1A35051A0C051A3B1A371A3C1A3D1A3E
1704030D1A35051A0C051A3F1A371A401A411A421704030D1A35051A0C051A43
1A371A441A451A461704030D1A35051A0C051A471A371A481A491A4A1704030D
1A4B1A4C1A4D1A4E171A4B070D1A4F1A501A511A52171A4F070D1A531A541A55
1A56171A53070D1A571A581A591A5A171A57070D1A5B1A5C1A5D1A5E171A5B07
0D1A5F1A601A611A62171A5F070D1A631A641A651A66171A630701
}