-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathByteCodePrimitives
50 lines (43 loc) · 2.09 KB
/
ByteCodePrimitives
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
\ Here is a sample set of primitives. These were found by taking the
\ Standard Forth core and some core extension words, and throwing out
\ the ones that cause trouble.
\ T: is the name of a command that assigns bytecodes to these words
\ on the tokenizer. The tokenizer also defines additional tokens
\ that require special treatment.
\ T: is also the name of a different command that assigns execution
\ tokens to byte tokens on the token compiler. The token compiler
\ has an additional T: ;T sequence to handle the special words that
\ didn't fit into this list.
\ T: is also the name of a third command that assigns names to tokens
\ on the detokenizer. There is a third T: ;T sequence to give new names
\ to the special words.
\ So to make a new byte-code system, you might start by noticing which
\ words you need, and create a list like this. Then you notice
\ which words require special attention. Those will be particularly
\ parsing words, compiling words, and defining words. They will each need
\ special treatment, probably in both the tokenizer and the token-compiler.
\ The words that don't need special treatment can go into this list.
T:
! # #> #S * */ */MOD + +! +LOOP ,
- . / /MOD 0< 0= 1+ 1- 2! 2* 2/
2@ 2DROP 2DUP 2OVER < <#
= > >BODY >IN >NUMBER >R ?DUP @
ABORT ABS ACCEPT ALIGN ALIGNED
ALLOT AND BASE BEGIN BL C! C, C@ CELL+
CELLS CHAR+ CHARS COUNT CR DO
DECIMAL DEPTH DROP DUP ELSE EMIT
EXECUTE EXIT FILL FM/MOD
HERE HOLD I IF IMMEDIATE INVERT
J KEY LEAVE LITERAL LOOP LSHIFT M*
MAX MIN MOD MOVE NEGATE OR OVER
QUIT R> R@ RECURSE REPEAT ROT RSHIFT S>D SIGN SM/REM
SOURCE SPACE SPACES STATE SWAP THEN TYPE U.
U< UM* UM/MOD UNLOOP UNTIL
WHILE WORD XOR .S
;T
\ WORD is the only one above that parses the input stream.
\ WORD should only be compiled into commands that will be executed
\ on the target, and that won't be expected to act on byte-code.
\ Since the byte-code is not a character input stream, WORD won't work on it.
\ Words that parse and words that compile will often need special treatment
\ in the tokenizer or the token-compiler or both.