An extensible POSIX-compatible implementation of the ed(1) text editor
git clone https://git.8pit.net/edward.git
1;;> This is a stripped-down and minimally modified version of [chibi parse][chibi parse], 2;;> a parser combinator library with optional memoization. This version of the library 3;;> is specifically designed to faciliate building read-eval-print loops with parser 4;;> combinators. 5;;> 6;;> Apart from [parse streams][stream section], the central abstraction of this libary 7;;> is therefore a [REPL][repl section] type which continously reads data from standard 8;;> input and parses this data with parsers constructed using provided parser combinators. 9;;>10;;> An exemplary parser may be constructed as follows:11;;>12;;> ```13;;> (import (srfi 14) (edward parse))14;;>15;;> (define hexadecimal16;;> (parse-map17;;> (parse-seq18;;> (parse-string "0x")19;;> (parse-map20;;> (parse-token char-set:hex-digit)21;;> (lambda (str)22;;> (string->number str 16))))23;;> cadr))24;;> ```25;;>26;;> This parser recognizes hexadecimal integers using the character set definition27;;> provided by [SRFI 14][srfi 14] and transform these characters into a Scheme28;;> number type using [parse-map][parse-map]. Refer to the documentation below29;;> for more information on available combinators.30;;>31;;> [chibi parse]: https://synthcode.com/scheme/chibi/lib/chibi/parse.html32;;> [stream section]: #section-parse-streams33;;> [repl section]: #section-read–eval–print-loop34;;> [srfi 14]: https://srfi.schemers.org/srfi-14/srfi-14.html35;;> [parse-map]: #parse-map3637(define-library (edward.parse)38 (import (scheme base)39 (scheme char)40 (scheme file)41 (scheme write)4243 (srfi 1)44 (srfi 14)4546 (edward util)4748 (only (chicken file posix) file-read file-close fileno/stdin)49 (only (chicken process signal) set-signal-handler! signal/int))5051 ;; repl.scm52 (export make-repl repl? repl-run repl-interactive repl-prompt? repl-set-prompt!)5354 ;; parse.scm55 (export call-with-parse parse parse-fully parse-fold parse-failure56 parse->list parse-fully->list57 file->parse-stream string->parse-stream parse-stream-substring58 parse-stream-start? parse-stream-end? parse-stream-ref59 parse-anything parse-nothing parse-epsilon60 parse-seq parse-and parse-or parse-not list->parse-seq61 parse-repeat parse-repeat+ parse-optional62 parse-map parse-map-substring parse-ignore parse-assert63 parse-atomic parse-commit parse-lazy parse-memoize64 parse-char parse-not-char65 parse-string parse-token66 parse-beginning parse-end67 parse-beginning-of-line parse-end-of-line68 parse-with-failure-reason69 make-parse-stream)7071 ;; parse-util.scm72 (export parse-fail parse-bind parse-as-string parse-digits parse-lowercase73 parse-default parse-newline parse-blank74 parse-blanks+ parse-blanks parse-between parse-esc75 parse-strip-blanks parse-blanks-seq parse-line parse-alist76 parse-with-context parse-regex-lit* parse-regex-lit)7778 (include "parse/repl.scm"79 "parse/parse.scm"80 "parse/util.scm"))