diff --git a/ueforth/Makefile b/ueforth/Makefile index ce3a2f1..a07c8db 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -278,28 +278,36 @@ $(ARDUINO)/ESP32forth.zip: $(ARDUINO)/ESP32forth/ESP32forth.ino $(DEPLOY): mkdir -p $@ +REPLACE = common/replace.js \ + COMMON=@site/common.html \ + DESKTOP_COMMON=@site/desktop_common.html \ + MENU=@site/menu.html \ + VERSION=${VERSION} \ + REVISION=${REVISION} +UE_REPLACE = $(REPLACE) FORTH=uEForth +ESP_REPLACE = $(REPLACE) FORTH=ESP32forth + $(DEPLOY)/app.yaml: $(ARDUINO)/ESP32forth.zip \ $(wildcard site/*.html) \ site/app.yaml \ site/eforth.go \ $(TARGETS) | $(DEPLOY) - cp -r site/* $(DEPLOY)/ - mkdir -p $(DEPLOY)/downloads + mkdir -p $(DEPLOY) + cp -r site/static $(DEPLOY)/static + cp -r site/downloads $(DEPLOY)/downloads + cp site/*.go $(DEPLOY)/ + cp site/*.yaml $(DEPLOY)/ cp -r $(ARDUINO)/ESP32forth.zip $(DEPLOY)/downloads cp -r $(POSIX)/ueforth $(DEPLOY)/downloads/ueforth.linux cp -r $(WINDOWS)/uEf32.exe $(DEPLOY)/downloads/uEf32.exe cp -r $(WINDOWS)/uEf64.exe $(DEPLOY)/downloads/uEf64.exe cp -r $(RES)/eforth.ico $(DEPLOY)/downloads/favicon.ico cp site/.gcloudignore $(DEPLOY) - cat site/ESP32forth.html | \ - sed "s/{{VERSION}}/${VERSION}/g" | \ - sed "s/{{REVISION}}/${REVISION}/g" > $(DEPLOY)/ESP32forth.html - cat site/windows.html | \ - sed "s/{{VERSION}}/${VERSION}/g" | \ - sed "s/{{REVISION}}/${REVISION}/g" > $(DEPLOY)/windows.html - cat site/linux.html | \ - sed "s/{{VERSION}}/${VERSION}/g" | \ - sed "s/{{REVISION}}/${REVISION}/g" > $(DEPLOY)/linux.html + cat site/index.html | $(ESP_REPLACE) >$(DEPLOY)/index.html + cat site/ESP32forth.html | $(ESP_REPLACE) >$(DEPLOY)/ESP32forth.html + cat site/linux.html | $(UE_REPLACE) >$(DEPLOY)/linux.html + cat site/windows.html | $(UE_REPLACE) >$(DEPLOY)/windows.html + cat site/classic.html | $(UE_REPLACE) >$(DEPLOY)/classic.html deploy: clean all cd out/deploy && gcloud app deploy -q --project esp32forth *.yaml diff --git a/ueforth/common/replace.js b/ueforth/common/replace.js new file mode 100644 index 0000000..403fbf7 --- /dev/null +++ b/ueforth/common/replace.js @@ -0,0 +1,36 @@ +#! /usr/bin/env nodejs + +var fs = require('fs'); + +var source = fs.readFileSync(process.stdin.fd).toString(); +var replacements = []; +for (var i = 2; i < process.argv.length; ++i) { + var item = process.argv[i]; + var m = item.match(/^([^=]+)=@(.+)$/); + if (m) { + replacements.push([m[1], fs.readFileSync(m[2]).toString()]); + continue; + } + var m = item.match(/^([^=]+)=(.+)$/); + if (m) { + replacements.push([m[1], m[2]]); + continue; + } + throw 'Bad replacement ' + item; +} + +var version = process.argv[3]; +var revision = process.argv[4]; + +for (;;) { + var old_source = source; + for (var i = 0; i < replacements.length; ++i) { + source = source.replace('{{' + replacements[i][0] + '}}', + replacements[i][1]); + } + if (old_source == source) { + break; + } +} + +process.stdout.write(source); diff --git a/ueforth/site/ESP32forth.html b/ueforth/site/ESP32forth.html index 63cb829..1151c81 100644 --- a/ueforth/site/ESP32forth.html +++ b/ueforth/site/ESP32forth.html @@ -8,13 +8,7 @@
-As null terminated strings are used throughout C interfaces, -their use is supported in Forth by way of several non-standard -words with the convention of using Z/z to refer to such strings -in names and stack comments. -
--Z" ( "string" -- z ) Creates a null terminated string on the heap -Z>S ( z -- a n ) Convert a null terminated string to a counted string -S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap) -+{{COMMON}} -
-Raw strings are provided better support using a string -for the duration of the current command, without consuming heap memory. -
--R" ( "string" -- a n ) Creates a temporary counted string -R| ( string| -- a n ) Creates a temporary counted string ending with | -- -
-DUMP ( a n -- ) Dump a memory region -SEE ( "name" -- ) Attempt to decompile a word -VARIABLE ECHO -- Determines if commands are echoed -- -
-ESP32forth uses a hybrid of Forth-79 and Forth-83 style vocabularies.
-By default vocabularies chain to the vocabulary in which they were defined,
-as in Forth-79. However, like Forth-83, ALSO
-can be used to add vocabularies to a vocabulary stack of which
-CONTEXT @ is the first item.
-The word ONLY clears the vocabulary stack, but as there is
-no separate ONLY vocabulary, it also sets CONTEXT
-to the FORTH vocabulary.
-The word SEALED modifies the most recently defined vocabulary
-such that it does not chain. Note, this must be done before words are added to it.
-
-VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
-FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
-DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
-VLIST ( -- ) List the words in the context vocabulary (not chains)
-WORDS ( -- ) List the words in the context vocabulary (including chains)
-TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
- Useful for "hiding" built-in words
-TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
-ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
-ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
- Non-standard, as there's no distinct ONLY vocabulary
-ORDER ( -- ) Print the vocabulary search order
-SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
-
-
-
-[I]F, [ELSE], and [THEN] can be used
-to selectively compile. Used in tandem with DEFINED? they can
-be used to handle the absence of modules gracefully.
-Nesting is supported.
-
-DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too). -[IF] ( f -- ) Conditionally interpret the text the follows. -[ELSE] ( -- ) Interpret time ELSE. -[THEN] ( -- ) Interpret time THEN. -- -
-USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo -OPEN-BLOCKS ( a n -- ) Open a file as the block file -LOAD ( n -- ) Evaluate a block -THRU ( a b -- ) Load blocks a thru b -LIST ( n -- ) List a block -BLOCK ( n -- a ) Get a 1024 byte block -BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents -UPDATE ( -- ) Mark the last block modified -FLUSH ( -- ) Save and empty all buffers -EMPTY-BUFFERS ( -- ) Empty all buffers -SAVE-BUFFERS ( -- ) Save all buffers -SCR ( -- a ) Pointer to last listed block -- -
EDITOR vocabulary.
-Note the block editor places newlines in the 63rd column of each line
-to make the block file readable in a text editor.
--WIPE ( -- ) Blank out the current block -L ( -- ) List the current block -D ( n -- ) Delete a line in the current block -E ( n -- ) Clear a line in the current block -R ( n "text" -- ) Replace a line in the current block -A ( n "text" -- ) Add (insert) a line in the current block -P ( -- ) Move to the previous block -N ( -- ) Move to the next block -- -
-SEE ( "name" -- ) Attempt to decompile a word -ECHO ( -- a ) -- Address of flag that determines if commands are echoed -- -
Because Arduino builds a statically linked image for flashing into ESP32 devices, diff --git a/ueforth/site/classic.html b/ueforth/site/classic.html index e67240f..d23a061 100644 --- a/ueforth/site/classic.html +++ b/ueforth/site/classic.html @@ -7,13 +7,7 @@
EForth is a delightfully minimalist approach to Forth originated by Bill Muench and Dr. C. H. Ting. diff --git a/ueforth/site/common.html b/ueforth/site/common.html new file mode 100644 index 0000000..c895072 --- /dev/null +++ b/ueforth/site/common.html @@ -0,0 +1,109 @@ +
+As null terminated strings are used throughout C interfaces, +their use is supported in Forth by way of several non-standard +words with the convention of using Z/z to refer to such strings +in names and stack comments. +
++Z" ( "string" -- z ) Creates a null terminated string on the heap +Z>S ( z -- a n ) Convert a null terminated string to a counted string +S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap) ++ +
+Raw strings are provided better support using a string +for the duration of the current command, without consuming heap memory. +
++R" ( "string" -- a n ) Creates a temporary counted string +R| ( string| -- a n ) Creates a temporary counted string ending with | ++ +
+DUMP ( a n -- ) Dump a memory region +SEE ( "name" -- ) Attempt to decompile a word +VARIABLE ECHO -- Determines if commands are echoed ++ +
+{{FORTH}} uses a hybrid of Forth-79 and Forth-83 style vocabularies.
+By default vocabularies chain to the vocabulary in which they were defined,
+as in Forth-79. However, like Forth-83, ALSO
+can be used to add vocabularies to a vocabulary stack of which
+CONTEXT @ is the first item.
+The word ONLY clears the vocabulary stack, but as there is
+no separate ONLY vocabulary, it also sets CONTEXT
+to the FORTH vocabulary.
+The word SEALED modifies the most recently defined vocabulary
+such that it does not chain. Note, this must be done before words are added to it.
+
+VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
+FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
+DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
+VLIST ( -- ) List the words in the context vocabulary (not chains)
+WORDS ( -- ) List the words in the context vocabulary (including chains)
+TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
+ Useful for "hiding" built-in words
+TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
+ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
+ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
+ Non-standard, as there's no distinct ONLY vocabulary
+ORDER ( -- ) Print the vocabulary search order
+SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
+
+
+
+[I]F, [ELSE], and [THEN] can be used
+to selectively compile. Used in tandem with DEFINED? they can
+be used to handle the absence of modules gracefully.
+Nesting is supported.
+
+DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too). +[IF] ( f -- ) Conditionally interpret the text the follows. +[ELSE] ( -- ) Interpret time ELSE. +[THEN] ( -- ) Interpret time THEN. ++ +
+USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo +OPEN-BLOCKS ( a n -- ) Open a file as the block file +LOAD ( n -- ) Evaluate a block +THRU ( a b -- ) Load blocks a thru b +LIST ( n -- ) List a block +BLOCK ( n -- a ) Get a 1024 byte block +BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents +UPDATE ( -- ) Mark the last block modified +FLUSH ( -- ) Save and empty all buffers +EMPTY-BUFFERS ( -- ) Empty all buffers +SAVE-BUFFERS ( -- ) Save all buffers +SCR ( -- a ) Pointer to last listed block ++ +
EDITOR vocabulary.
+Note the block editor places newlines in the 63rd column of each line
+to make the block file readable in a text editor.
++WIPE ( -- ) Blank out the current block +L ( -- ) List the current block +D ( n -- ) Delete a line in the current block +E ( n -- ) Clear a line in the current block +R ( n "text" -- ) Replace a line in the current block +A ( n "text" -- ) Add (insert) a line in the current block +P ( -- ) Move to the previous block +N ( -- ) Move to the next block ++ +
+SEE ( "name" -- ) Attempt to decompile a word +ECHO ( -- a ) -- Address of flag that determines if commands are echoed +diff --git a/ueforth/site/desktop_common.html b/ueforth/site/desktop_common.html new file mode 100644 index 0000000..62b9149 --- /dev/null +++ b/ueforth/site/desktop_common.html @@ -0,0 +1,28 @@ + +
+As unfortunately both Windows and Linux have system and library calls with
+as many as 10 parameters (for example XCreateImage),
+a collection of calling thunks is required.
+A single varidic thunk would be ideal, but is hard to do without per platform
+assembly language.
+
+CALL0 ( fn -- n ) +CALL1 ( n fn -- n ) +CALL2 ( n n fn -- n ) +CALL3 ( n n n fn -- n ) +CALL4 ( n n n n fn -- n ) +CALL5 ( n n n n n fn -- n ) +CALL6 ( n n n n n n fn -- n ) +CALL7 ( n n n n n n n fn -- n ) +CALL7 ( n n n n n n n n fn -- n ) +CALL9 ( n n n n n n n n n fn -- n ) +CALL10 ( n n n n n n n n n n fn -- n ) ++ +
+See calling.h. +
diff --git a/ueforth/site/internals.html b/ueforth/site/internals.html index 2de3354..f92afd0 100644 --- a/ueforth/site/internals.html +++ b/ueforth/site/internals.html @@ -7,13 +7,7 @@µEforth (micro-Eforth) simplifies EForth even futher, by building just enough diff --git a/ueforth/site/linux.html b/ueforth/site/linux.html index 25b6299..d1d2ca8 100644 --- a/ueforth/site/linux.html +++ b/ueforth/site/linux.html @@ -7,13 +7,7 @@
-As null terminated strings are used by virtually all platforms, -their use is supported in Forth by way of several non-standard -words with the convention of using Z/z to refer to such strings -in names and stack comments. -
--Z" ( "string" -- z ) Creates a null terminated string on the heap -Z>S ( z -- a n ) Convert a null terminated string to a counted string -S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap) -- -
-Raw strings are provided better support using a string -for the duration of the current command, without consuming heap memory. -
--R" ( "string" -- a n ) Creates a temporary counted string -R| ( string| -- a n ) Creates a temporary counted string ending with | -- -
-DUMP ( a n -- ) Dump a memory region -SEE ( "name" -- ) Attempt to decompile a word -VARIABLE ECHO -- Determines if commands are echoed -- -
-µEforth uses a hybrid of Forth-79 and Forth-83 style vocabularies.
-By default vocabularies chain to the vocabulary in which they were defined,
-as in Forth-79. However, like Forth-83, ALSO
-can be used to add vocabularies to a vocabulary stack of which
-CONTEXT @ is the first item.
-The word ONLY clears the vocabulary stack, but as there is
-no separate ONLY vocabulary, it also sets CONTEXT
-to the FORTH vocabulary.
-The word SEALED modifies the most recently defined vocabulary
-such that it does not chain. Note, this must be done before words are added to it.
-
-VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
-FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
-DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
-VLIST ( -- ) List the words in the context vocabulary (not chains)
-WORDS ( -- ) List the words in the context vocabulary (including chains)
-TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
- Useful for "hiding" built-in words
-TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
-ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
-ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
- Non-standard, as there's no distinct ONLY vocabulary
-ORDER ( -- ) Print the vocabulary search order
-SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
-
-
-
-[I]F, [ELSE], and [THEN] can be used
-to selectively compile. Used in tandem with DEFINED? they can
-be used to handle the absence of modules gracefully.
-Nesting is supported.
-
-DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too). -[IF] ( f -- ) Conditionally interpret the text the follows. -[ELSE] ( -- ) Interpret time ELSE. -[THEN] ( -- ) Interpret time THEN. -- -
-USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo -OPEN-BLOCKS ( a n -- ) Open a file as the block file -LOAD ( n -- ) Evaluate a block -THRU ( a b -- ) Load blocks a thru b -LIST ( n -- ) List a block -BLOCK ( n -- a ) Get a 1024 byte block -BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents -UPDATE ( -- ) Mark the last block modified -FLUSH ( -- ) Save and empty all buffers -EMPTY-BUFFERS ( -- ) Empty all buffers -SAVE-BUFFERS ( -- ) Save all buffers -SCR ( -- a ) Pointer to last listed block -- -
EDITOR vocabulary.
-Note the block editor places newlines in the 63rd column of each line
-to make the block file readable in a text editor.
--WIPE ( -- ) Blank out the current block -L ( -- ) List the current block -D ( n -- ) Delete a line in the current block -E ( n -- ) Clear a line in the current block -R ( n "text" -- ) Replace a line in the current block -A ( n "text" -- ) Add (insert) a line in the current block -P ( -- ) Move to the previous block -N ( -- ) Move to the next block -- -
-SEE ( "name" -- ) Attempt to decompile a word -ECHO ( -- a ) -- Address of flag that determines if commands are echoed -+{{COMMON}}
TYPE and KEY are connected to
stdin and stdout.
-
-As unfortunately both Windows and Linux have system and library calls with
-as many as 10 parameters (for example XCreateImage),
-a collection of calling thunks is required.
-A single varidic thunk would be ideal, but is hard to do without per platform
-assembly language.
-
-CALL0 ( fn -- n ) -CALL1 ( n fn -- n ) -CALL2 ( n n fn -- n ) -CALL3 ( n n n fn -- n ) -CALL4 ( n n n n fn -- n ) -CALL5 ( n n n n n fn -- n ) -CALL6 ( n n n n n n fn -- n ) -CALL7 ( n n n n n n n fn -- n ) -CALL7 ( n n n n n n n n fn -- n ) -CALL9 ( n n n n n n n n n fn -- n ) -CALL10 ( n n n n n n n n n n fn -- n ) -- -
-See calling.h. -
+{{DESKTOP_COMMON}} diff --git a/ueforth/site/windows.html b/ueforth/site/windows.html index 664b86d..984b7d5 100644 --- a/ueforth/site/windows.html +++ b/ueforth/site/windows.html @@ -7,13 +7,7 @@-As null terminated strings are used by virtually all platforms, -their use is supported in Forth by way of several non-standard -words with the convention of using Z/z to refer to such strings -in names and stack comments. -
--Z" ( "string" -- z ) Creates a null terminated string on the heap -Z>S ( z -- a n ) Convert a null terminated string to a counted string -S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap) -- -
-Raw strings are provided better support using a string -for the duration of the current command, without consuming heap memory. -
--R" ( "string" -- a n ) Creates a temporary counted string -R| ( string| -- a n ) Creates a temporary counted string ending with | -- -
-DUMP ( a n -- ) Dump a memory region -SEE ( "name" -- ) Attempt to decompile a word -VARIABLE ECHO -- Determines if commands are echoed -- -
-µEforth uses a hybrid of Forth-79 and Forth-83 style vocabularies.
-By default vocabularies chain to the vocabulary in which they were defined,
-as in Forth-79. However, like Forth-83, ALSO
-can be used to add vocabularies to a vocabulary stack of which
-CONTEXT @ is the first item.
-The word ONLY clears the vocabulary stack, but as there is
-no separate ONLY vocabulary, it also sets CONTEXT
-to the FORTH vocabulary.
-The word SEALED modifies the most recently defined vocabulary
-such that it does not chain. Note, this must be done before words are added to it.
-
-VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
-FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
-DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
-VLIST ( -- ) List the words in the context vocabulary (not chains)
-WORDS ( -- ) List the words in the context vocabulary (including chains)
-TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
- Useful for "hiding" built-in words
-TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
-ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
-ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
- Non-standard, as there's no distinct ONLY vocabulary
-ORDER ( -- ) Print the vocabulary search order
-SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
-
-
-
-[I]F, [ELSE], and [THEN] can be used
-to selectively compile. Used in tandem with DEFINED? they can
-be used to handle the absence of modules gracefully.
-Nesting is supported.
-
-DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too). -[IF] ( f -- ) Conditionally interpret the text the follows. -[ELSE] ( -- ) Interpret time ELSE. -[THEN] ( -- ) Interpret time THEN. -- -
-USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo -OPEN-BLOCKS ( a n -- ) Open a file as the block file -LOAD ( n -- ) Evaluate a block -THRU ( a b -- ) Load blocks a thru b -LIST ( n -- ) List a block -BLOCK ( n -- a ) Get a 1024 byte block -BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents -UPDATE ( -- ) Mark the last block modified -FLUSH ( -- ) Save and empty all buffers -EMPTY-BUFFERS ( -- ) Empty all buffers -SAVE-BUFFERS ( -- ) Save all buffers -SCR ( -- a ) Pointer to last listed block -- -
EDITOR vocabulary.
-Note the block editor places newlines in the 63rd column of each line
-to make the block file readable in a text editor.
--WIPE ( -- ) Blank out the current block -L ( -- ) List the current block -D ( n -- ) Delete a line in the current block -E ( n -- ) Clear a line in the current block -R ( n "text" -- ) Replace a line in the current block -A ( n "text" -- ) Add (insert) a line in the current block -P ( -- ) Move to the previous block -N ( -- ) Move to the next block -- -
-SEE ( "name" -- ) Attempt to decompile a word -ECHO ( -- a ) -- Address of flag that determines if commands are echoed -+{{COMMON}}
TYPE and KEY.
-
-As unfortunately both Windows and Linux have system and library calls with
-as many as 10 parameters (for example XCreateImage),
-a collection of calling thunks is required.
-A single varidic thunk would be ideal, but is hard to do without per platform
-assembly language.
-
-CALL0 ( fn -- n ) -CALL1 ( n fn -- n ) -CALL2 ( n n fn -- n ) -CALL3 ( n n n fn -- n ) -CALL4 ( n n n n fn -- n ) -CALL5 ( n n n n n fn -- n ) -CALL6 ( n n n n n n fn -- n ) -CALL7 ( n n n n n n n fn -- n ) -CALL7 ( n n n n n n n n fn -- n ) -CALL9 ( n n n n n n n n n fn -- n ) -CALL10 ( n n n n n n n n n n fn -- n ) -- -
-See calling.h. -
- +{{DESKTOP_COMMON}}