Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the recursive-regex Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Apr 19 17:37:23 2021 GMT+0.
• Introduction | What recursive-regex is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
This library integrates with CL-PPCRE to make named regex groups dispatch to custom matcher functions, which can recursively call another regex in the context of the original regex. It can then return a (parse) tree of results.
Modularize common regexp patterns so more reuse can be had
Allow non-regular expression matches by defering to custom match functions
Named groups matched in * expressions return all their results rather than the last match only (full parse tree of results, based on the named dispatchers)
Easy to expand your extant regular expressions to return better results (ie, I don't need to replce cl-ppcre with some parse, I can just keep using cl-ppcre)
Currently doesnt support a streaming interface
Not as well founded theoretically as other parser kits (ie: there are no shift/reduce or reduce/reduce errors flagged)
Not tested or optimized for performance.
(regex-recursive-groups #?r"function\s*(?<parens>)"
"looking for function(call(), 1 ,2) type things")
>> #<RESULT-NODE ROOT s:12 e:34 kids:1 "function(call(), 1 ,2)" {1003341731}>
(:ROOT "function(call(), 1 ,2)"
(:MATCHED-PARENS "(call(), 1 ,2)"))
NB: Currently returns clos object trees and lisp-trees, because I want to play with it in the repl and see results but in practicality the CLOS result is probably what I want to work with.
body:
can be used in a definition to designate where the body
matcher should start matching. You can also provide a default
body by specifying a regex inside the body in a definition.
parens, brackets, braces, angels:
these all match a single matched pair
eg, for parens:
not in the match (in (the) match) not in the match
single-quotes, double-quotes:
single-quotes and double-quotes respect a single backslash as escape
comma-list:
[\t ]*(?:(?<body>[^,]*)[\t ]*,)*[\t ]*(?<body>[^,]*)[\t ]*
the comma-list definition is (?<body>) separated by commas with
arbitrary whitespace surrounding them. The default value of the
body regex os [^,]*
csv-row:
(?<comma-list>((?<double-quotes>)|[^\n,]*))(?:\n|$)
calls the comma-list matcher passing in the body
double-quotes-matcher or not new line or comma repeating
I'm obviously not the first person to think this idea would be neat
Balanced capture groups
This blog post talks about balanced expressions available in .net
Perl, leading the way in hackery as ever has a couple of different ways to embed regexps' recursively
A blog post discussing embedding a PERL regexp inside its own definition
;; Copyright (c) 2011 Russ Tyndall,
;; Acceleration.net http://www.acceleration.net
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
;;
;; - Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;;
;; - Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The recursive-regex system |
BSD
Recursive regular expression parsing engine
0.1
recursive-regex.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The recursive-regex.asd file | ||
• The recursive-regex/rec-regex.lisp file | ||
• The recursive-regex/rex-reader.lisp file |
Next: The recursive-regex/rec-regex․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
recursive-regex.asd
recursive-regex (system)
Next: The recursive-regex/rex-reader․lisp file, Previous: The recursive-regex․asd file, Up: Lisp files [Contents][Index]
recursive-regex (system)
rec-regex.lisp
Previous: The recursive-regex/rec-regex․lisp file, Up: Lisp files [Contents][Index]
recursive-regex (system)
rex-reader.lisp
read-rex-file-to-dispatchers (function)
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The recursive-regex.system package | ||
• The recursive-regex package |
Next: The recursive-regex package, Previous: Packages, Up: Packages [Contents][Index]
recursive-regex.asd
Previous: The recursive-regex․system package, Up: Packages [Contents][Index]
rec-regex.lisp (file)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
rec-regex.lisp (file)
rec-regex.lisp (file)
Next: Exported generic functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
Add a new body matcher that dispatches on name
rec-regex.lisp (file)
Add a matched pair matcher dispatched on name
rec-regex.lisp (file)
Add a new dispatcher on name to child regex
rec-regex.lisp (file)
removes all the dispatchers
rec-regex.lisp (file)
Allows named registers to refer to functions that should be in the place of the named register
rec-regex.lisp (file)
Creates a default dispatch table with a parens dispatcher that can match pairs of parentheses
rec-regex.lisp (file)
reads a set of definitions in from a rex file, calls
add-named-regex-matcher for each production
name => regex
rex-reader.lisp (file)
run a recursive regular expression and gather all the results for each of them into a tree
rec-regex.lisp (file)
rec-regex.lisp (file)
Make a lisp tree of the results of the matches from the clos tree
rec-regex.lisp (file)
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
automatically generated reader method
rec-regex.lisp (file)
automatically generated writer method
rec-regex.lisp (file)
automatically generated reader method
rec-regex.lisp (file)
automatically generated writer method
rec-regex.lisp (file)
automatically generated reader method
rec-regex.lisp (file)
automatically generated writer method
rec-regex.lisp (file)
automatically generated reader method
rec-regex.lisp (file)
automatically generated writer method
rec-regex.lisp (file)
automatically generated reader method
rec-regex.lisp (file)
automatically generated writer method
rec-regex.lisp (file)
automatically generated reader method
rec-regex.lisp (file)
automatically generated writer method
rec-regex.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
rec-regex.lisp (file)
standard-object (class)
:name
name (generic function)
(setf name) (generic function)
:start
start (generic function)
(setf start) (generic function)
:end
end (generic function)
(setf end) (generic function)
:full-match
full-match (generic function)
(setf full-match) (generic function)
:groups
groups (generic function)
(setf groups) (generic function)
:kids
kids (generic function)
(setf kids) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal macros | ||
• Internal functions | ||
• Internal generic functions | ||
• Internal conditions |
Next: Internal macros, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rex-reader.lisp (file)
rex-reader.lisp (file)
rex-reader.lisp (file)
rex-reader.lisp (file)
Next: Internal functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
pushes child-matches into the place and continues-matching discards results that have been backtracked passed
rec-regex.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
rec-regex.lisp (file)
Whenever we meet a named group, change it to a named dispatcher if we find it in the list we use that matcher, otherwise we use a body matcher.
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rec-regex.lisp (file)
rex-reader.lisp (file)
quotes in rex productions should be direct string matches (not regex)
rex-reader.lisp (file)
rec-regex.lisp (file)
Handles matching the body of a named regular expression
rec-regex.lisp (file)
rec-regex.lisp (file)
Will create a regex filter that can match arbitrary pairs of matched characters such as (start (other () some) end)
rec-regex.lisp (file)
Handles matching by delegating to another named regular expression
rec-regex.lisp (file)
rex-reader.lisp (file)
rex-reader.lisp (file)
rex-reader.lisp (file)
Returns a new string in which all the occurences of the part
is replaced with replacement. [FROM http://cl-cookbook.sourceforge.net/strings.html#manip]
rex-reader.lisp (file)
If we encounter {name} style definitions in the right hand side replace them with their text (regex fragment) value
rex-reader.lisp (file)
read a line and trim it, if it is empty return nil instead of empty string
rex-reader.lisp (file)
find the index of an unescaped quote
rex-reader.lisp (file)
Next: Internal conditions, Previous: Internal functions, Up: Internal definitions [Contents][Index]
rec-regex.lisp (file)
Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
rec-regex.lisp (file)
condition (condition)
:data
(quote nil)
data (generic function)
(setf data) (generic function)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L R |
---|
Jump to: | F L R |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | %
(
A C D E F G H I K M N O P R S T U W |
---|
Jump to: | %
(
A C D E F G H I K M N O P R S T U W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
+
D E F G K N S |
---|
Jump to: | *
+
D E F G K N S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C I P R S |
---|
Jump to: | C I P R S |
---|