Prcc is a PEG-like combinator parser library by packrat parsing. Inspired by ruby gem rsec.
chicken-install prcc
(use prcc)
(define parser
(<and>
(<@> (<s> "hello")
(lambda (o) "hello "))
(<s> "world")
(eof)))
(display (parse-string "helloworld" parser))
(newline)
(char c)
: generate a parser that read a char- alias
<c>
- alias
(seq parser [parsers ...])
: sequence parser- alias
<and>
- alias
(sel parser [parsers ...])
: branch parser and ordered selected- alias
<or>
- alias
(one? parser)
: appear 0 or 1 time- alias
<?>
- alias
(rep parser)
: repeat 0 to infinite times- alias
<*>
- alias
(rep+ parser)
: repeat 1 to infinite times- alias
<+>
- alias
(pred parser0 parser1)
: lookahead predicate parser1- alias
<&>
- alias
(pred! parser0 parser1)
: negative lookahead- alias
<&!>
- alias
(eof)
: end of file(act parser [succ-proc] [fail-proc])
: mutate parser and be used to process the output of a parser- alias
<@>
- alias
(neg parser)
: take parser failure as pass- alias
<^>
- alias
(regexp-parser string [chunk-size])
- alias
<r>
- alias
(lazy parser)
(cached parser)
: cache parser result- helpers
(str string)
: a string parser- alias
<s>
- alias
(one-of string)
: parse one of chars in string(join+ parser0 parser1)
: repeat parser0 with parser1 inserted(join+_ parser0 parser1 [skip: (<s*>)])
: skip spaces by default(ind seq-parser index)
: return the value that is indicated by index- alias
<#>
- alias
<w>
: word<w*>
<w+>
<space>
: space<s*>
<s+>
(rep_ parser [skip: (<s*>)])
: skip spaces by default- alias
<*_>
- alias
(rep+_ parser [skip: (<s*>)])
: skip spaces by default- alias
<+_>
- alias
(seq_ parser [parser...] [skip: (<s*>)])
: skip spaces by default- alias
<and_>
- alias
(even parser)
: return even elements of sequence(odd parser)
: return odd elements of sequence
(parse-file filename parser [cache])
: by default, no cache(parse-string string parser [cache])
(parse-port port parser [cache])