| Paste number 53252: | seq implementation |
| Pasted by: | |Agent |
| 6 months, 3 weeks ago | |
| #dylan | Context in IRC logs | |
| Paste contents: |
| define method seq (#rest sub-rules :: <function>) => (rule :: <function>) method (stream) => (success, tokens) let pos = stream.stream-position; let product = make(<stretchy-sequence>); let failed = #f; for (rule in sub-rules, until: failed) let (success, tokens) = rule(stream); if (success) product := product.add!(tokens) else failed := rule end if end for; if (failed) stream.stream-position := pos; product := make(<parser-error>, format-string: "Expected %s", format-args: $rule-names[rule]) end if; values(~failed, product) end method end method; |
This paste has no annotations.