1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; UrForth level
1: self
-hosting
32-bit Forth compiler
3 ;; Copyright
(C
) 2020 Ketmar Dark
// Invisible Vector
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 compiler
:?comp compiler
:?non
-macro latest
-cfa compile
,
12 compiler
:?comp compiler
:?non
-macro latest
-cfa compile lit
-exectail reladdr
,
16 : [CHAR
] ( -- ch
) \ word
17 parse
-name
1 <> err
-char
-expected ?error
26 : ['] ( -- cfa
) \ word
32 : (COMPILE
-CFA
-LITERAL
) ( cfa
-- )
37 : COMPILE
( -- ) \ word
38 compiler
:?comp
-find
-required
42 : [COMPILE
] ( -- ) \ word
43 compiler
:?comp
-find
-required compile
,
46 : [EXECUTE
-TAIL
] ( -- ) \ word
47 compiler
:?comp
-find
-required compile lit
-exectail reladdr
,
51 ;; ANS idiocity
, does this
:
52 ;; if the next word is immediate
, compiles it in the current word
53 ;; if the next word is not immediate
, compiles
"compile nextword"
55 compiler
:?comp
-find
-required
-ex
-if
56 ;; not immediate
, do what
"COMPILE" does
59 ;; immediate
, do what
"[COMPILE]" does
88 skip
-comment
-multiline
91 ;; nested multiline comment
94 skip
-comment
-multiline
-nested
98 ;; this copies string
to PAD
if it needs
to be unscaped
, or
99 ;; if we
're using default TIB
100 : (parse-and-unescape) ( ch -- addr count )
101 parse dup ifnot exit endif
103 ;; check for backslash
104 2dup [char] \ str-char-index
108 dup #pad-area cell- u> err-string-too-long ?error
109 over >r >r pad r@ move
111 ;; it can never be bigger that the original, so it is save to compare here
112 2dup r> r> 2dup 2>r s= if
119 : " ( -- addr count ) \ word ;; "
120 34 (parse-and-unescape) [compile] sliteral
126 : ." ( -- ) \ word ;; "
127 34 (parse-and-unescape)
129 ['] (.") compiler:custom-c1sliteral,
136 [char] ) (parse-and-unescape) type