diff --git a/README.md b/README.md index 2b893fa..f5f3035 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # quickforth +proof of concept running arbitrary forth in a cgi-bin like env + +## Requirements + +- retro forth + +- quickserv + +## Getting Started + +1. run `quickserv_macos_x64` in a terminal (or download/install/build/etc an apropriate binary for your computer) + +2. Open http://localhost:42069 + +## Resources + +- retro - http://forth.works/book.html + +- quickserv - https://github.com/jstrieb/quickserv diff --git a/calculate/index.retro b/calculate/index.retro new file mode 100644 index 0000000..23c5626 --- /dev/null +++ b/calculate/index.retro @@ -0,0 +1,10 @@ +#!retro + +arguments are passed like "--first x --second y" etc + +~~~ +#1 script:get-argument s:to-number +#3 script:get-argument s:to-number ++ +'The_answer_is_%n s:format s:put +~~~ diff --git a/index.html b/index.html new file mode 100644 index 0000000..5aaabcc --- /dev/null +++ b/index.html @@ -0,0 +1,6 @@ +

wanna add some stuff?

+
+ + = ??? +
+ +
diff --git a/justfile b/justfile new file mode 100644 index 0000000..31e4179 --- /dev/null +++ b/justfile @@ -0,0 +1,7 @@ +# show all commands +default: + @just --list + +# look up a word and describe it +describe: + @cat words.txt | fzf | xargs retro-describe diff --git a/quickserv_macos_x64 b/quickserv_macos_x64 new file mode 100755 index 0000000..d4941eb Binary files /dev/null and b/quickserv_macos_x64 differ diff --git a/words.txt b/words.txt new file mode 100644 index 0000000..681e3cc --- /dev/null +++ b/words.txt @@ -0,0 +1,517 @@ +s:index-of +s:index-of +a:index-of-string +a:index-of +a:contains-string? +s:contains-string? +s:contains-char? +s:split-on-string +s:split +d:words-beginning-with +d:words-with +d:words +listen +banner +// +bye +NoEcho +clear +s:get-word +s:get +parse-until +image:save +TIB +clock:utc:second +clock:utc:minute +clock:utc:hour +clock:utc:year +clock:utc:month +clock:utc:day +clock:second +clock:minute +clock:hour +clock:year +clock:month +clock:day +clock:timestamp +clock:operation +abort +script:abort-include +script:ignore-to-eol +script:current-line +script:current-file +script:name +include +script:get-argument +script:arguments +socket:configure +socket:close +socket:recv +socket:send +socket:connect +socket:accept +socket:listen +socket:bind +socket:create +socket:gethostbyname +socket:operation +n:random +unix:slurp-pipe +unix:for-each-file +unix:count-files-in-cwd +unix:get-cwd +unix:pipe +unix:sleep +unix:putenv +unix:getenv +unix:chdir +unix:pclose +unix:popen +unix:kill +unix:wait +unix:getpid +unix:exit +unix:exec3 +unix:exec2 +unix:exec1 +unix:exec0 +unix:fork +unix:system +io:unix-syscall +e:put +f:dump-astack +f:dump-stack +f:fetch +f:store +e:to-f +f:to-e +f:signed-square +f:signed-sqrt +f:E1 +e:clip +e:-inf? +e:inf? +e:nan? +e:zero? +e:min? +e:max? +e:n? +e:-INF +e:INF +e:NAN +e:MIN +e:MAX +f:sign +f:case +f:dec +f:inc +f:between? +f:limit +f:max +f:min +f:round +f:-inf? +f:inf? +f:nan? +f:-INF +f:INF +f:NAN +f:E +f:PI +f:put +f:abs +f:negate +f:negative? +f:positive? +f:square +sigil:. +f:rot +f:dup-pair +f:drop-pair +f:nip +f:tuck +f:over +f:adepth +f:pop +f:push +f:atan +f:acos +f:asin +f:tan +f:cos +f:sin +f:power +f:log +f:swap +f:drop +f:dup +f:depth +f:gt? +f:lt? +f:-eq? +f:eq? +f:sqrt +f:ceiling +f:floor +f:/ +f:* +f:- +f:+ +f:to-string +f:to-number +s:to-float +n:to-float +float:operation +file:spew +file:slurp +file:for-each-line +file:read-line +file:open-for-writing +file:open-for-append +file:open-for-reading +file:exists? +file:flush +file:delete +file:size +file:seek +file:tell +file:write +file:read +file:close +file:open +file:R+ +file:A +file:W +file:R +file:operation +listen +s:get +c:get +FREE +dump-stack +reset +n:put +s:put +tab +sp +nl +c:put +io:scan-for +io:invoke +io:query +io:enumerate +hex +octal +binary +decimal +indexed-times +K +J +I +s:evaluate +a:ends-with? +a:begins-with? +a:-eq? +a:eq? +a:middle +a:right +a:left +} +{ +a:make +a:index/string +a:index +a:reduce +a:store +a:fetch +a:th +a:reverse +a:map +a:contains/string? +a:contains? +a:filter +a:chop +a:prepend +a:append +a:to-string +a:copy +a:dup +a:for-each +a:from-string +a:counted-results +a:length +d:lookup-xt +d:for-each +does +curry +reorder +s:const +s:format +n:to-string +s:replace-all +s:tokenize-on-string +s:tokenize +s:replace +s:split/string +s:split/char +sigil:' +RewriteUnderscores +s:trim +s:trim-right +s:trim-left +s:to-lower +s:to-upper +c:to-number +c:toggle-case +c:to-string +c:to-lower +c:to-upper +c:-consonant? +c:-vowel? +c:-visible? +c:-whitespace? +c:-digit? +c:-uppercase? +c:-lowercase? +c:whitespace? +c:consonant? +c:vowel? +c:visible? +c:digit? +c:letter? +c:uppercase? +c:lowercase? +ASCII:US +ASCII:RS +ASCII:GS +ASCII:FS +ASCII:SUB +ASCII:EM +ASCII:CAN +ASCII:ETB +ASCII:SYN +ASCII:NAK +ASCII:DC4 +ASCII:DC3 +ASCII:DC2 +ASCII:DC1 +ASCII:DLE +ASCII:SI +ASCII:SO +ASCII:BEL +ASCII:ACK +ASCII:ENQ +ASCII:EOT +ASCII:ETX +ASCII:STX +ASCII:SOH +ASCII:DEL +ASCII:SPACE +ASCII:CR +ASCII:FF +ASCII:VT +ASCII:LF +ASCII:HT +ASCII:BS +ASCII:ESC +ASCII:NUL +$ +' +s:WHITESPACE +s:PUNCTUATION +s:ASCII-LETTERS +s:ASCII-UPPERCASE +s:ASCII-LOWERCASE +s:DIGITS +s:copy +s:ends-with? +s:begins-with? +s:left +s:right +s:substr +s:map +s:filter +s:index/string +s:contains/string? +s:hash +s:contains/char? +s:index/char +s:for-each +s:append +s:prepend +s:reverse +s:chop +sigil:' +s:keep +s:skip +s:empty +s:temp +STRINGS +TempStringMax +TempStrings +buffer:preserve +buffer:set +buffer:size +buffer:empty +buffer:get +buffer:add +buffer:end +buffer:start +}} +---reveal--- +{{ +ScopeList +copy +v:update +v:preserve +allot +v:off +v:on +v:limit +v:dec +v:inc +v:dec-by +v:inc-by +n:between? +n:dec +n:inc +n:limit +n:abs +n:max +n:min +n:sqrt +n:square +n:negate +n:pow +mod +/ +rot +-if: +if: +-if; +if; +n:odd? +n:even? +n:strictly-positive? +n:positive? +n:negative? +n:-zero? +n:zero? +n:MIN +n:MAX +gteq? +lteq? +not +s:case +case +FALSE +TRUE +sigil:| +times +until +while +tri@ +tri* +tri +bi@ +bi* +bi +sip +dip +dup-pair +?dup +drop-pair +nip +over +tuck +const +var +var-n +d:create +sigil:! +sigil:@ +here +sigil:^ +sigil:\ +sigil:` +compiling? +compile:ret +compile:call +compile:jump +compile:lit +) +( +unhook +set-hook +hook +primitive +data +immediate +reclass +d:last.name +d:last.class +d:last.xt +d:last +depth +EOM +err:notfound +Base +r +d +i +Version +class:primitive +d:lookup +interpret +again +repeat +sigil:$ +sigil:& +sigil:: +sigil:# +d:add-header +class:data +class:macro +class:word +d:name +d:class +d:xt +d:link +Dictionary +] +[ +; +s, +, +Heap +Compiler +sigil:( +-if +if +choose +s:length +s:eq? +s:to-number +store-next +fetch-next +0; +pop +push +shift +xor +or +and +/mod +* +- ++ +store +fetch +gt? +lt? +-eq? +eq? +call +swap +drop +dup