Last active
August 29, 2015 14:20
-
-
Save rgchris/4159dd40eb2eda76e2ae to your computer and use it in GitHub Desktop.
Fleshing out a model for a COLLECT/KEEP in Parse based on correctness.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebol [ | |
Title: "Fleshing out a model for a COLLECT/KEEP in Parse based on correctness" | |
Date: 26-Apr-2015 | |
Author: "Christopher Ross-Gill" | |
] | |
buckets: [] | |
new-branch: quote (insert/only buckets bucket: copy []) | |
fold-branch: quote (bucket: buckets/2 append bucket take buckets) | |
kill-failed-branch: quote (remove buckets) | |
if probe parse [a b c][ | |
new-branch | |
'a (append bucket 'a) ; keep 'a | |
[ | |
new-branch | |
'b (append bucket 'b) ; keep 'b | |
'd (append bucket 'd) ; keep 'd | |
; successful end of rule | |
fold-branch | |
| | |
; rule failed, so | |
kill-failed-branch | |
new-branch | |
'b (append bucket 'b) ; keep 'b | |
'c (append bucket 'c) ; keep 'c | |
; successful end of rule | |
fold-branch | |
] | |
][ | |
probe bucket | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebol [ | |
Title: "Fleshing out a model for a COLLECT/KEEP in Parse based on correctness" | |
Date: 26-Apr-2015 | |
Author: "Christopher Ross-Gill" | |
] | |
buckets: [] | |
if probe parse [a b c][ | |
(insert/only buckets bucket: copy []) | |
'a (append bucket 'a) ; keep 'a | |
[ | |
(insert/only buckets bucket: copy []) | |
'b (append bucket 'b) ; keep 'b | |
'd (append bucket 'd) ; keep 'd | |
; successful end of rule | |
(bucket: buckets/2 append bucket take buckets) | |
| | |
; rule failed, so | |
(remove buckets) | |
(insert/only buckets bucket: copy []) | |
'b (append bucket 'b) ; keep 'b | |
'c (append bucket 'c) ; keep 'c | |
; successful end of rule | |
(bucket: buckets/2 append bucket take buckets) | |
] | |
][ | |
probe bucket | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment