[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
11.4 Options and user definitions
Options act as parameters that are transmitted to the parser on the call
to read/rp
. Local defines are user functions inserted in the produced
parser, at the same level as the pre-defined ignore
function.
Here is an example of grammar using both
(define gram (regular-grammar (x y) (define (foo s) (cons* 'foo x s (ignore))) (define (bar s) (cons* 'bar y s (ignore))) ((+ #\a) (foo (the-string))) ((+ #\b) (bar (the-string))) (else '())))
This grammar uses two options x and y. Hence when invokes it takes two additional values such as:
(with-input-from-string "aabb" (lambda () (read/rp gram (current-input-port) 'option-x 'option-y))) ⇒ (foo option-x aa bar option-y bb)
This document was generated on March 31, 2014 using texi2html 5.0.