/usr/share/doc/cl-esrap/README is in cl-esrap 20140826-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | ESRAP -- a packrat parser for Common Lisp
In addition to regular Packrat / Parsing Grammar / TDPL features ESRAP
supports:
- dynamic redefinition of nonterminals
- inline grammars
- semantic predicates
- introspective facilities (describing grammars, tracing, setting breaks)
- left-recursive grammars
- functions as terminals
Homepage & Documentation:
http://scymtym.github.com/esrap/
References:
* Bryan Ford, 2002, "Packrat Parsing: a Practical Linear Time
Algorithm with Backtracking".
http://pdos.csail.mit.edu/~baford/packrat/thesis/
* A. Warth et al, 2008, "Packrat Parsers Can Support Left
Recursion".
http://www.vpri.org/pdf/tr2007002_packrat.pdf
Licence:
Copyright (c) 2007-2013 Nikodemus Siivola <nikodemus@random-state.net>
Copyright (c) 2012-2014 Jan Moringen <jmoringe@techfak.uni-bielefeld.de>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Syntax overview:
<literal> -- case-sensitive terminal
(~ <literal>) -- case-insensitive terminal
character -- any single character
(string <length>) -- any string of length
(character-ranges <ranges>) -- character ranges
(<predicate> <expr>) -- semantic parsing
(function <function>) -- call <function> to parse some text
(not <expr>) -- complement of expression
(and &rest <exprs>) -- sequence
(or &rest <exprs>) -- ordered-choices
(* <expr>) -- greedy-repetition
(+ <expr>) -- greedy-positive-repetition
(? <expr>) -- optional
(& <expr>) -- followed-by; does not consume
(! <expr>) -- not-followed-by; does not consume
Example files:
- example-sexp.lisp: complete sample grammar and usage
- example-symbol-table.lisp: grammar with lexical scope
- example-left-recursion.lisp: multiple grammars with left recursion
- example-function-terminal.lisp: grammars with functions as terminals
Trivial examples:
;; Parse takes a expression
(parse '(or "foo" "bar") "foo") => "foo", NIL
;; New rules can be added.
;;
;; Normally you'd use the declarative DEFRULE interface to define new
;; rules, but everything it does can be done directly by building
;; instances of the RULE class and using ADD-RULE to activate them.
(add-rule 'foo+ (make-instance 'rule :expression '(+ "foo"))) => FOO+
(parse 'foo+ "foofoofoo") => ("foo" "foo" "foo"), NIL
;; Rules can transform their matches.
(add-rule 'decimal
(make-instance 'rule
:expression '(+ (or "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
:transform (lambda (list start end)
(declare (ignore start end))
(parse-integer (format nil "~{~A~}" list)))))
=> DECIMAL
;; Any lisp function can be used as a semantic predicate.
(parse '(oddp decimal) "123") => 123
(parse '(evenp decimal) "123" :junk-allowed t) => NIL, 0
|