From philipp at marek.priv.at Sun Sep 30 07:53:58 2012 From: philipp at marek.priv.at (Philipp Marek) Date: Sun, 30 Sep 2012 09:53:58 +0200 Subject: [cl-ppcre-devel] debugging of RE matching Message-ID: <2895c7b70e5acf9306c75993b3501dc3.squirrel@webmail.hitco.org> Hello everybody, to make it easier to see how/where a RE does (or does not) match I've started a branch on github: https://github.com/phmarek/cl-ppcre/tree/debugging During compile-time cl-ppcre::*do-debug* decides whether some tracing output is returned by the compiled match function. Example for a successful match: > (cl-ppcre:scan-to-strings #?r(^abc(d|(e+)|fff)[xyz]+) "abcfffzzxzx") *string*: "abcfffzzxzx" SEQ [ 0 0[ ANCHOR [ 0 0[ ANCHOR STR [ 0 3[ "abc" REGISTER [ 3 3[ $1 ALTERNATION [ 3 3[ STR [ 3 3[ "" REGISTER [ 3 3[ $2 SEQ [ 3 3[ STR [ 3 3[ "" STR [ 3 6[ "fff" CHAR-CLASS [ 6 7[ [# (cl-ppcre:scan-to-strings #?r(^abc(d|(e+)|fff)[xyz]+) "abcffffz") *string*: "abcffffz" SEQ [ 0 0[ ANCHOR [ 0 0[ ANCHOR STR [ 0 3[ "abc" REGISTER [ 3 3[ $1 ALTERNATION [ 3 3[ STR [ 3 3[ "" REGISTER [ 3 3[ $2 SEQ [ 3 3[ STR [ 3 3[ "" STR [ 3 6[ "fff" CHAR-CLASS NO MATCH [# References: <2895c7b70e5acf9306c75993b3501dc3.squirrel@webmail.hitco.org> Message-ID: Phil, your change seems useful, but I wonder why you added an extra lambda layer instead of doing the binding in the function returned by create-scanner-aux match-fn. Is there a reason for that? The html document is the source for the documentation. I'd give the symbol that enables debugging a more specific name which contains the fact that match debugging is enabled and export it from the :cl-ppcre package. -Hans On Sun, Sep 30, 2012 at 9:53 AM, Philipp Marek wrote: > > Hello everybody, > > to make it easier to see how/where a RE does (or does not) match I've started > a branch on github: > > https://github.com/phmarek/cl-ppcre/tree/debugging > > During compile-time cl-ppcre::*do-debug* decides whether some tracing output > is returned by the compiled match function. > > Example for a successful match: > > > (cl-ppcre:scan-to-strings #?r(^abc(d|(e+)|fff)[xyz]+) "abcfffzzxzx") > *string*: "abcfffzzxzx" > SEQ [ 0 0[ > ANCHOR [ 0 0[ ANCHOR > STR [ 0 3[ "abc" > REGISTER [ 3 3[ $1 > ALTERNATION [ 3 3[ > STR [ 3 3[ "" > REGISTER [ 3 3[ $2 > SEQ [ 3 3[ > STR [ 3 3[ "" > STR [ 3 6[ "fff" > CHAR-CLASS [ 6 7[ [# REPETITION [ 7 11[ > "abcfffzzxzx" > #("fff" NIL) > > > Example for a non-matching try: > > > (cl-ppcre:scan-to-strings #?r(^abc(d|(e+)|fff)[xyz]+) "abcffffz") > *string*: "abcffffz" > SEQ [ 0 0[ > ANCHOR [ 0 0[ ANCHOR > STR [ 0 3[ "abc" > REGISTER [ 3 3[ $1 > ALTERNATION [ 3 3[ > STR [ 3 3[ "" > REGISTER [ 3 3[ $2 > SEQ [ 3 3[ > STR [ 3 3[ "" > STR [ 3 6[ "fff" > CHAR-CLASS NO MATCH [# NIL > > I think this might be useful for other people, so please provide some > feedback. > > Is the documentations' source doc/index.html? Then I'd provide some text > there, too. > > > > Regards, > > Phil > > > > > _______________________________________________ > cl-ppcre-devel site list > cl-ppcre-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-ppcre-devel From edi at agharta.de Sun Sep 30 09:17:56 2012 From: edi at agharta.de (Edi Weitz) Date: Sun, 30 Sep 2012 11:17:56 +0200 Subject: [cl-ppcre-devel] debugging of RE matching In-Reply-To: References: <2895c7b70e5acf9306c75993b3501dc3.squirrel@webmail.hitco.org> Message-ID: In addition to what Hans said I'd consider using a special variable like *debug-stream* instead of *do-debug* so that you can direct debugging information to a particular stream. Also, not only the HTML documentation should be patched, all newly-introduced functions should also have meaningful docstrings, and the docstrings for the new special variables should adhere to the style rules of the rest of the code - use whole sentences, don't start with lower-case chars, don't use abbreviations, etc. Finally, the documentation should explain that the debugging output will not always reflect the regular expression that was originally entered because the regex engine might have optimized it before debugging kicks in. Thanks, Edi. On Sun, Sep 30, 2012 at 10:52 AM, Hans H?bner wrote: > Phil, > > your change seems useful, but I wonder why you added an extra lambda > layer instead of doing the binding in the function returned by > create-scanner-aux match-fn. Is there a reason for that? > > The html document is the source for the documentation. I'd give the > symbol that enables debugging a more specific name which contains the > fact that match debugging is enabled and export it from the :cl-ppcre > package. > > -Hans > > On Sun, Sep 30, 2012 at 9:53 AM, Philipp Marek wrote: >> >> Hello everybody, >> >> to make it easier to see how/where a RE does (or does not) match I've started >> a branch on github: >> >> https://github.com/phmarek/cl-ppcre/tree/debugging >> >> During compile-time cl-ppcre::*do-debug* decides whether some tracing output >> is returned by the compiled match function. >> >> Example for a successful match: >> >> > (cl-ppcre:scan-to-strings #?r(^abc(d|(e+)|fff)[xyz]+) "abcfffzzxzx") >> *string*: "abcfffzzxzx" >> SEQ [ 0 0[ >> ANCHOR [ 0 0[ ANCHOR >> STR [ 0 3[ "abc" >> REGISTER [ 3 3[ $1 >> ALTERNATION [ 3 3[ >> STR [ 3 3[ "" >> REGISTER [ 3 3[ $2 >> SEQ [ 3 3[ >> STR [ 3 3[ "" >> STR [ 3 6[ "fff" >> CHAR-CLASS [ 6 7[ [#> REPETITION [ 7 11[ >> "abcfffzzxzx" >> #("fff" NIL) >> >> >> Example for a non-matching try: >> >> > (cl-ppcre:scan-to-strings #?r(^abc(d|(e+)|fff)[xyz]+) "abcffffz") >> *string*: "abcffffz" >> SEQ [ 0 0[ >> ANCHOR [ 0 0[ ANCHOR >> STR [ 0 3[ "abc" >> REGISTER [ 3 3[ $1 >> ALTERNATION [ 3 3[ >> STR [ 3 3[ "" >> REGISTER [ 3 3[ $2 >> SEQ [ 3 3[ >> STR [ 3 3[ "" >> STR [ 3 6[ "fff" >> CHAR-CLASS NO MATCH [#> NIL >> >> I think this might be useful for other people, so please provide some >> feedback. >> >> Is the documentations' source doc/index.html? Then I'd provide some text >> there, too. >> >> >> >> Regards, >> >> Phil >> >> >> >> >> _______________________________________________ >> cl-ppcre-devel site list >> cl-ppcre-devel at common-lisp.net >> http://common-lisp.net/mailman/listinfo/cl-ppcre-devel > > _______________________________________________ > cl-ppcre-devel site list > cl-ppcre-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-ppcre-devel >