X-Git-Url: https://git.kengrimes.com/?p=watForth.git;a=blobdiff_plain;f=forth.forth;h=47224b9fd5be28b7a1e02989d034630e9d638f65;hp=dce37c5b7833fcff87ea467ecf2be56b1bf3878c;hb=18b72639839461c074eb18fc2b58aa2a326485a1;hpb=7946a78988064b7ec67e8d27763a962cebb29515 diff --git a/forth.forth b/forth.forth index dce37c5..47224b9 100644 --- a/forth.forth +++ b/forth.forth @@ -57,6 +57,7 @@ word WS? 17 define word . 9 define word .S 38 define word @ 10 define +word @8_u 53 define word @+ 42 define word ! 11 define word !+ 43 define @@ -92,7 +93,7 @@ word ::> here define ' drop , ' lit , ' lit , ' , , ' execute-num , ' , , ' ; , \ change interpreter semantics to "memorize-word" -: memorizing ' lit , ' mode , ' lit , ' memorize-word , ' ! , ' ; , +::> MEMORIZING ' lit , ' mode , ' lit , ' memorize-word , ' ! , ' ; , \ memorize the compiler \memorizing @@ -139,15 +140,42 @@ here define-does then compiling ; \ Multi-line comments ::> ( key 41 =? swap -1 =? swap drop + if ;; then JMP: \' ( \, ; -\ Set the number conversion base -: BASE 14348 swap ! ; -: BASE10 10 base ; - ( End of bootstrap process beyond this point, all hope is lost ) +\ Set the number conversion base +: BASE 14348 swap ! ; +: BASE10 10 base ; + +\ TICK compilation semantics +:> ' lit lit , word find , ; +\ "TICK DOES" (get compilation semantics execution token) +: '> word find-does ; +:> '> word find-does , ; + +\ CHAR +: CHAR: word drop @8_u ; +:> CHAR: lit lit , ' char: execute , ; + +\ JSON Compiler +: JSON-CTRL-CHAR char: { =? if ;; then + char: } =? if ;; then + char: [ =? if ;; then ; +: JSON-PARSE-V ; +: JSON-PARSE-" ; +: JSON-PARSE-[ ; +: JSON-PARSE-{ ; +:> JSON-WORD wordstart key -1 =? if ;; then ws? ; + + +\ Include a remote file +: REQUIRE" ' quit channel-open dup \' " \, fetch channel-await ; + +\ Let's try it +REQUIRE" { \"url\": \"forth/test-watfor.forth\" }" + \ Print intro string " watForth-32 Interactive CLI: " .s