From c60d503590dd86f605b81bc57f425c323c724083 Mon Sep 17 00:00:00 2001 From: Drahflow Date: Mon, 28 Aug 2017 20:11:10 +0200 Subject: Does not actually with bare compiler --- examples/working-loaded/interactive-stack.test | 196 +++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 examples/working-loaded/interactive-stack.test (limited to 'examples/working-loaded/interactive-stack.test') diff --git a/examples/working-loaded/interactive-stack.test b/examples/working-loaded/interactive-stack.test new file mode 100644 index 0000000..0365280 --- /dev/null +++ b/examples/working-loaded/interactive-stack.test @@ -0,0 +1,196 @@ +{ scope }' =*globalScope + +< + map ==seenThings # from .hu of rawAddress to some name + map ==usedNames # from name to rawAddress + + { ==suggested ==thing + thing sys .asm .rawAddress _ ==a txt .produce .hu ==as + + globalScope keys { ==name + globalScope name .| sys .asm .rawAddress _ ==a txt .produce .hu ==as + + "\e[2m" name cat "\e[0m" cat =name + name as seenThings =[] + a name usedNames =[] + } each + + { ==i + i 0 eq { + i suggested * + } { + i suggested len math .base suggested * |cat fold + } ? * + } /toName deffst + + as seenThings .has { + as seenThings * + } { + 0 ==i + { + i toName ==name + name usedNames .has + }' { + { 1 add } |=i + }' loop + + name as seenThings =[] + a name usedNames =[] + name + } ? * + } +> -- /niceName deffd + +{ [ "α" "β" "γ" "δ" "ε" "π" "φ" ] niceName } /niceScopeName deffd + +< + [ 0 11 range { + sys .asm .intToFloat + }' each ] =*:FLOAT + + sys .out .|writeall =*out + + "0123456789" ==:base10digits + "0123456789ABCDEF" ==:base16digits + + { _ 0 lt { neg "-" }' { "" }' ? * -01 + [ -01 16 { _ 16 umod base16digits * -01 16 udiv }' rep -- ] reverse str .fromArray cat + }' /base16encode64 deffd + + { "\e[1;31m\e[0m" out }" /unknown defvd + + [ + { "\e[31m" o txt .produce .i cat "\e[0m" cat out }" # integer + { "\e[31m\"" o "\"\e[0m" cat cat out }" # string + { "\e[31m" out o { ==f 0 ==e "+" ==s 0 ==i + f 0 FLOAT lt { 0 FLOAT f sub =f "-" =s }' rep + { f 1 FLOAT lt i 500 lt and }' { f 10 FLOAT mul =f e 1 sub =e i 1 add =i }' loop + { f 10 FLOAT ge i 500 lt and }' { f 10 FLOAT div =f e 1 add =e i 1 add =i }' loop + + i 500 eq { + s + f 1 FLOAT lt "0.0e0" "inf" ? + cat out + }' { + { + 0 ==d + 1 10 range { ==i f i FLOAT gt { i =d }' rep } each + f d sub =f + f 10 FLOAT mul =f + d base10digits * + } /extractDigit deffst + + [ + 0 s * + extractDigit + 0 "." * + 10 |extractDigit rep + 0 "e" * + e 0 lt { + 0 e sub =e + 0 "-" * + } rep + e 0 eq { + 0 "0" * + } rep + [ + { e } { + e 10 mod base10digits * + e 10 div =e + } loop + ] reverse _ len dearray + ] str .fromArray out + }' ? * + } * "\e[0m" out }" # float + unknown + unknown # extension area + { "\e[32m{" + o [ /f /g /h /a /b /c /d /e ] niceName cat + "\e[32m}\e[0m" cat out + }" + unknown + { "\e[36m[" + o [ /A /B /C /D /E /F /G /H ] niceName cat + "\e[36m]\e[0m" cat out + }" # array + unknown # function type + { "\e[35m<" + o niceScopeName cat + "\e[35m>\e[0m" cat out + }" + unknown # name table + unknown # stack + { "" cat out }" + unknown + unknown + unknown + { "[" out }" + { "{" out }" + { "\e[34m|\e[0m" out }" + unknown + ] /dumpActions deffd + + # dump top stack element + { _ ==o sys .typed .type dumpActions * " " out } + + # dump entire stack + { 0 ==i "" ==x + { x sys .typed .type 18 neq } { + i _' =x + { 1 add } |=i + } loop + + { 1 sub } |=i + + { i 0 ge } { + i _' =x + { 1 sub } |=i + x objectdump + " " out + } loop + + "\n" out + } +> -- /stackdump deffd /objectdump deffd + +"Welcome to elymas.\n" sys .out .writeall + +{ _ ==openedScope enincludeLine =*eval + 1 ==running + { 0 =running } =*quit + + { running } { + "\n" sys .out .writeall + "\e[35m" "scope" eval niceScopeName cat "\e[34m:\e[0m" cat sys .out .writeall + "scope" eval _ ==curScope keys { ==name + name existingGlobals .has not { + " " sys .out .writeall name "=" cat sys .out .writeall curScope name .| objectdump + } rep + } each + "\n" sys .out .writeall + stackdump + + [ "\e[34m>" sys .out .writeall + quoted { "\e[32m{" } rep "\e[0m \e[1m" ] |cat fold sys .out .writeall + 65536 sys .in .read "\e[0m" sys .out .writeall _ len { ==line + line "^(.*)\n$" regex { + eval + } { + "non-terminal input" dump + } ? * + } { -- + 0 =running + } ? * + } loop +} /open deffd + +map ==existingGlobals +globalScope keys { ==name + 1 name existingGlobals =[] +} each + +scope open + +"\n" sys .out .writeall + +# vim: syn=elymas -- cgit v1.2.3