;; generated automatically.  DO NOT EDIT
#!no-fold-case
(define-module parser.peg (use srfi-13) (use srfi-14) (use gauche.collection) (use gauche.generator) (use gauche.lazy) (use text.tree) (use util.match) (export <parse-error> make-peg-parse-error peg-run-parser peg-parse-string peg-parse-port peg-parser->generator parse-success? return-result return-failure/expect return-failure/unexpect return-failure/message return-failure/compound $return $fail $expect $lift $lift* $debug $do $try $seq $or $fold-parsers $fold-parsers-right $many $many1 $skip-many $skip-many1 $repeat $optional $alternate $sep-by $end-by $sep-end-by $count $between $followed-by $not $many-till $chain-left $chain-right $lazy $any $eos $. $symbol $string $string-ci $char $one-of $none-of $many-chars $satisfy $match $match1 $->rope $->string $->symbol rope->string rope-finalize))
(select-module parser.peg)
(dynamic-load "parser--peg")
(define-syntax $do (syntax-rules () ((_ body) body) ((_ (var parser) clause . rest) ($bind parser (^ (var) ($do clause . rest)))) ((_ (parser) clause . rest) ($bind parser (^_ ($do clause . rest)))) ((_ parser clause . rest) ($bind parser (^_ ($do clause . rest)))) ((_ . other) (syntax-error "malformed $do" ($do . other)))))
(define-syntax $lazy (syntax-rules () ((_ parse) (let ((p (delay parse))) (lambda (s) ((force p) s))))))
(define-syntax $satisfy (syntax-rules () ((_ pred expect) ($satisfy pred expect identity)) ((_ pred expect result) (lambda (s) (if-let1 v (and (pair? s) (pred (car s))) (return-result (result (car s) v) (cdr s)) (return-failure/expect expect s))))))
(define-syntax $match (syntax-rules () ((_ (pat ...) result) (lambda (s) (match s ((pat ... . rest) (return-result result rest)) (_ (return-failure/expect (write-to-string '(pat ...)) s))))) ((_ (pat ... . rest) result) (lambda (s) (match s ((pat ... . rest) (return-result result '())) (_ (return-failure/expect (write-to-string '(pat ... . rest)) s))))) ((_ (pat ...)) (lambda (s) (match s ((pat ... . rest) (return-result (take s (length '(pat ...))) rest)) (_ (return-faiulre/expect (write-to-string '(pat ...)) s))))) ((_ (pat ... . rest)) (lambda (s) (match s ((pat ... . rest) (return-result s '())) (_ (return-faiulre/expect (write-to-string '(pat ... . rest)) s)))))))
(define-syntax $match1 (syntax-rules () ((_ pat result) (lambda (s) (if (pair? s) (match (car s) (pat (return-result result (cdr s))) (_ (return-failure/expect (write-to-string 'pat) s))) (return-faiulre/expect (write-to-string 'pat) s)))) ((_ pat) (lambda (s) (if (pair? s) (match (car s) (pat (return-result (car s) (cdr s))) (_ (return-failure/expect (write-to-string 'pat) s))) (return-faiulre/expect (write-to-string 'pat) s))))))
(define-syntax $many-chars (syntax-rules () ((_ parser) ($many ($one-of parser))) ((_ parser min) ($many ($one-of parser) min)) ((_ parser min max) ($many ($one-of parser) min max))))
