Re: Ann: regex pack

Michael Hendricks <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAFHuXubTPkPX_N6nu0TM07jVE6YhFA16rK2se7A7_SnUjiSgbQ@mail.gmail.com>
Oops, I packaged v0.2.0 incorrectly which caused an error message about the
"regex/captures" module.  The mistake is fixed in v0.2.1 which is now
available for download.  I've also adjusted my pack release
tool<https://github.com/mndrix/gift>to try to catch these kinds of
mistakes earlier next time.

Thanks to Chris Mungall for reporting the error.


-- 
Michael


On Fri, Oct 4, 2013 at 2:16 PM, Michael Hendricks <[email protected]> wrote:

> The latest release (v0.2.0) automatically unifies named regex captures
> with corresponding variables in the surrounding scope.  For example,
>
>   "Hi John" =~ "hi (?<Name>[a-z]+)"/i,
>   Name == "John".
>
> I'm enjoying it so far.  This is one more feature made possible by
> prolog_load_context(variable_names,_).  Thanks again Jan for adding that.
>
>
> --
> Michael
>
>
> On Fri, Sep 13, 2013 at 1:49 PM, Michael Hendricks <[email protected]>wrote:
>
>> I love DCGs as much as the next Prolog fan, but sometimes a tiny regular
>> expression will do the job.  Or perhaps regular expressions are part of
>> your app's UI.  Anyway, this pack<http://www.swi-prolog.org/pack/list?p=regex>supports many features of Perl compatible regex (see link for full support).
>>
>> As the semantic version number indicates, the API is very early and will
>> probably change. It currently uses =~ (as do Haskell and Perl), but that
>> gives no access to captured values.  A YAP-compatible API would support
>> captures so I might do that.  I'd also love to use
>> prolog_load_context(variable_names, _) with regex named captures to
>> automatically bind clause variables by name.
>>
>> I considered supporting quasiquotation (so one doesn't have to escape all
>> the slashes), but decided for now that a regex that complex should probably
>> be rewritten as a DCG anyway.
>>
>> The regular expression engine is currently a naive interpreter.  I partly
>> did that so that I have an interpreter to play with as I experiment with
>> some partial evaluation ideas.  It would be cool to partially evaluate the
>> regex interpreter against a regex to generate fast, concise Prolog code.
>>
>> Last thought: I tried to design the library to support pluggable regex
>> engines.  The idea is that one just adds a single line:
>>
>>     :- use_module(library(regex/engine/re2)).
>>
>> and your regular expressions are now handled by the re2 engine<https://code.google.com/p/re2/> (or
>> PCRE or POSIX or ...).  Any interest in such things?  I've used similar
>> tools to good effect in both Haskell and Perl.
>>
>> --
>> Michael
>>
>
>
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.