1 ;; Native x86 GNU/Linux Forth System, Direct Threaded Code
3 ;; Copyright (C) 2020 Ketmar Dark // Invisible Vector
5 ;; This program is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, version 3 of the License ONLY.
9 ;; This program is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;; GNU General Public License for more details.
14 ;; You should have received a copy of the GNU General Public License
15 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 urword_forth
"RECURSE",recurse
21 UF latestcfa compile_comma
25 urword_forth
"[CHAR]",imm_char
29 UF
1 nequ errid_char_expected qerror
36 UF mfind
not errid_word_expected qerror
40 urword_forth
"(COMPILE)",par_compile
45 UF rpop dup cellinc rpush @ compile_comma
48 urword_forth
"COMPILE",compile
51 UF qcomp mfind
not errid_word_expected qerror
56 urword_forth
"[COMPILE]",imm_compile
60 UF mfind
not errid_word_expected qerror
64 ;; ANS idiocity, does this:
65 ;; if the next word is immediate, compiles it in the current word
66 ;; if the next word is not immediate, compiles "compile nextword"
68 urword_forth
"POSTPONE",imm_postpone
71 UF qcomp mfind
not errid_word_expected qerror
72 UF dup cfa2nfa nfa2ffa ffapeek par_wflag_immediate
and
80 urword_forth
"[",lsqparen
86 urword_forth
"]",rsqparen
92 urword_forth
"(",comment_lparen
97 urword_forth
'\',comment_toeol
99 ;; check last delimiter
100 UF par_last_read_char @ 10 equal
110 UF drop tib_peekch 10 equal
124 urword_alias ";;",comment_toeol_semisemi,comment_toeol
126 urword_alias "//",comment_toeol_slashslash,comment_toeol
131 urword_forth "(*",comment_multiline
137 UF 42 equal tib_peekch 41 equal and
139 UF tib_getch drop exit
144 ; nested multiline comment
146 urword_forth "(+",comment_multiline_nested
148 UF 1 ; current comment level
153 UF 8 lshift tib_peekch or
154 UF dup 0x282b equal ;; (+?
156 UF drop tib_getch drop 1inc
158 UF 0x2b29 equal ;; +)
160 UF tib_getch drop 1dec
172 urword_forth "(PARSE-COMPILE-C4STR)",par_parse_compile_strlit
176 ; unescape it (we don't need returned data
)
177 UF count str_unescape swap celldec
! ;; update length
180 ; compile string literal (with trailing zero byte, not included in count)
181 ;; this is either noop, or real copy (due to DP-TEMP)
182 UF word_here here over count_only cellinc move
183 UF here count_only cellinc allot
186 UF word_here pad word_here count_only cellinc cmove pad count
187 ; put trailing 0 (not included in count)
192 urword_forth
'"',double_quote
194 ;; ( -- addr count ) \ word
197 ; compile string literal
200 UF par_parse_compile_strlit
203 urword_alias
'S"',sdquote
,double_quote
207 urword_forth
'(.")',pardottype
210 UF rpeek count
type rpop count
+ 1inc rpush
214 urword_forth
'."',dot_double_quote
219 ; compile string literal
222 UF par_parse_compile_strlit
229 urword_forth
".(",dot_lparen
232 UF
41 parse_to_here count str_unescape
type
236 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
237 ;; UrForth level 1 already has it in the kernel, so i have to move it here
238 urword_forth
"[']",imm_tick
244 urword_forth
"CFALITERAL",cfaliteral