- (act PARSER [SUCC-PROC] [FAIL-PREC])procedure
Act on the result of the parser, whether it's success or failure.
This allows you to add semantic actions to the parser.
Note: Be sure not to return #f in SUCC-PROC, because that will be filtered out.
Example:
(define a-or-b (sel (char #\a) (char #\b))) (parse-string "aabba" (rep (act a-or-b (lambda (x) (if (string=? "a" x) 'yes 'no))))) => (yes yes no no yes)