Skip to content

Commit 194fc25

Browse files
committed
reform system-words
1 parent a8a631f commit 194fc25

File tree

4 files changed

+45
-63
lines changed

4 files changed

+45
-63
lines changed

highlight-reds.red

Lines changed: 0 additions & 25 deletions
This file was deleted.

highlight.red

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
Red []
22
#include %system-words.red
33

4-
words: system-words/system-words
5-
6-
result: clear ""
7-
append result "("
8-
forall words [
9-
str: to string! words/1
10-
replace/all str "\" "\\\\"
11-
replace/all str "?" "\\?"
12-
replace/all str "*" "\\*"
13-
replace/all str "." "\\."
14-
replace/all str "+" "\\+"
15-
replace/all str "|" "\\|"
16-
replace/all str "$" "\\$"
17-
replace/all str "^^" "\\^^"
18-
append result str
19-
append result "|"
4+
to-regex: func [words [block!]][
5+
result: clear ""
6+
append result "("
7+
forall words [
8+
str: to string! words/1
9+
replace/all str "\" "\\\\"
10+
replace/all str "?" "\\?"
11+
replace/all str "*" "\\*"
12+
replace/all str "." "\\."
13+
replace/all str "+" "\\+"
14+
replace/all str "|" "\\|"
15+
replace/all str "$" "\\$"
16+
replace/all str "^^" "\\^^"
17+
append result str
18+
append result "|"
19+
]
20+
remove back tail result
21+
append result ")"
2022
]
21-
remove back tail result
22-
append result ")"
23-
print result
23+
24+
print "Red words: "
25+
print to-regex system-words/get-words no
26+
print "Red/System words: "
27+
print to-regex system-words/get-words yes

semantic.red

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,11 +1375,8 @@ completion: context [
13751375
]
13761376
]
13771377
]
1378-
either system? [
1379-
words: [?? as assert size? if either case switch until while loop any all exit return break continue catch declare use null context with comment true false func function alias]
1380-
][
1381-
words: system-words/system-words
1382-
]
1378+
1379+
words: system-words/get-words system?
13831380
forall words [
13841381
sys-string: to string! words/1
13851382
if find/match sys-string string [
@@ -1822,7 +1819,7 @@ completion: context [
18221819
complete-sys-path: function [][
18231820
tstr: find/tail/last pure-path "/"
18241821
tstr: copy/part pure-path tstr
1825-
unless system-words/system? fword [exit]
1822+
unless system-words/keyword? no fword [exit]
18261823
if error? result: try [red-complete-ctx/red-complete-path pure-path no][
18271824
exit
18281825
]
@@ -2187,7 +2184,7 @@ completion: context [
21872184
if datatype? get word [
21882185
return rejoin [params/label " is a base datatype!"]
21892186
]
2190-
return system-words/get-word-info word
2187+
return system-words/get-word-info no word
21912188
]
21922189
if all [
21932190
params/data
@@ -2216,7 +2213,7 @@ completion: context [
22162213
params/data/path
22172214
][
22182215
path: load params/data/path
2219-
return system-words/get-path-info path
2216+
return system-words/get-path-info no path
22202217
]
22212218
if all [
22222219
params/data
@@ -2358,11 +2355,11 @@ completion: context [
23582355
]
23592356

23602357
hover-keyword: function [word [word!]][
2361-
if system-words/system? word [
2358+
if system-words/keyword? no word [
23622359
if datatype? get word [
23632360
return rejoin [mold word " is a base datatype!"]
23642361
]
2365-
return system-words/get-word-info word
2362+
return system-words/get-word-info no word
23662363
]
23672364
none
23682365
]
@@ -2374,7 +2371,7 @@ completion: context [
23742371
]
23752372
path/1: word
23762373
]
2377-
system-words/get-path-info to path! path
2374+
system-words/get-path-info no to path! path
23782375
]
23792376

23802377
hover: function [uri [string!] line [integer!] column [integer!]][

system-words.red

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Red [
88
]
99

1010
system-words: context [
11-
get-words: has [sys words] [
11+
get-red-words: has [sys words] [
1212
sys: words-of system/words
1313
words: make block! length? sys
1414
forall sys [
@@ -18,19 +18,25 @@ system-words: context [
1818
]
1919
words
2020
]
21-
system-words: get-words
22-
system?: func [word [word!]][
23-
to logic! find system-words word
21+
red-words: get-red-words
22+
reds-words: [?? as assert size? if either case switch until while loop any all exit return break continue catch declare use null context with comment true false func function alias]
23+
get-words: func [system? [logic!]][
24+
either system? [reds-words][red-words]
25+
]
26+
keyword?: func [system? [logic!] word [word!]][
27+
to logic! find either system? [reds-words][red-words] word
2428
]
2529

26-
get-word-info: func [word [word!]][
27-
either find system-words word [
30+
get-word-info: func [system? [logic!] word [word!]][
31+
if system? [return none]
32+
either find red-words word [
2833
help-string :word
2934
][none]
3035
]
3136

32-
get-path-info: func [path [path!]][
33-
either find system-words path/1 [
37+
get-path-info: func [system? [logic!] path [path!]][
38+
if system? [return none]
39+
either find red-words path/1 [
3440
n: copy path
3541
while [
3642
all [

0 commit comments

Comments
 (0)