[REBOL] Parse does not have "not" match type. Re:(3)
From: lmecir:geocities at: 31-Jul-2000 14:45
Hi,
the latest version (see below) is better (the generated rule can
be used recursively if needed):
A-B-rule: func [
{Generate an A-B parse rule}
A [block!] {A-rule}
B [block!] {B-rule}
/local o
] [
o: make object! [
A-rule: A
B-rule: B
res-rule: none
]
bind/copy [
(self)
[
B-rule (res-rule: [to end skip]) |
(res-rule: A-rule)
]
res-rule
] in o 'self
]
{
Example:
a: [any "a" "b"]
b: ["aa"]
a-b: a-b-rule a b
parse "ab" a-b
parse "aab" a-b
}
not-rule: func [
"Generate a not A parse rule"
A [block!] {A-rule}
/local o
] [
o: make object! [
A-rule: A
res-rule: none
]
bind/copy [
(self)
[
A-rule (res-rule: [to end skip]) |
(res-rule: [])
]
res-rule
] in o 'self
]
{
Example:
a: [any "a" "b"]
not-a: not-rule a
parse "ab" not-a
parse "b" not-a
parse "" not-a
}