forked from rebolsource/r3
/
parse-let.test.reb
52 lines (48 loc) · 1020 Bytes
/
parse-let.test.reb
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
51
52
; %parse-let.test.reb
;
; Analog to LET in normal code.
; Until variadic combinators exist, only the SET-WORD! version exists.
; Multi-return is also TBD.
; Check usages inside GROUP!
(
x: 10
did all [
#a = parse "a" [let x: <any> (x)]
x = 10
]
)
(
x: 10
did all [
#a = parse "a" [let x: <any> [[(x)]]]
x = 10
]
)
; Check usages in rules
(
rule: "golden"
did all [
'b = parse [['a 'b] a b] [let rule: <any> rule]
rule = "golden"
]
)
(
rule: "golden"
did all [
'b = parse [['a 'b] a b] [let rule: <any> [[rule]]]
rule = "golden"
]
)
; https://forum.rebol.info/t/question-about-binding-in-parse/461
(
[hello -hi-there-] = collect [
function-rule: [
subparse group! [
let code: word!
try some [integer! | function-rule]
(keep code)
]
]
parse x: copy/deep [(-hi-there- 1 2 3 (hello 2 3 4))] function-rule
]
)