Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-10

Last missing benchmark: regex-dna

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vincent Snijders

The regex-dna benchmark
(http://shootout.alioth.debian.org/debian/benchmark.php?test=regexdna&lang=all) is the last missing benchmark.

Although fpc has a regexpr unit:
http://svn.freepascal.org/svn/fpc/trunk/packages/base/regexpr/regexpr.pp It has many todos, such as adding support for | in the search expression. So this unit doesn't have enough functionality. Is somebody willing to invest time in this unit to complete it?

An alternative could be to use the libc unit. But the fpc developers don't encourage its use and I cannot use it on windows, where I develop and improve the tests.

Then there is also synregexpr.pas:
http://svn.freepascal.org/svn/lazarus/trunk/components/synedit/synregexpr.pas But that is not distrubuted with fpc. And I don't know, if the license is open source. Is it looks likes a BSD derivative, but item 3, about income, doesn't seem to fit in.

How should this benchmark be implemented?

Vincent

Krishna
to Vincent Snijders
Vincent Snijders wrote 20 lines
The regex-dna benchmark (http://shootout.alioth.debian.org/debian/benchmark.php?test=regexdna&lang=all) is the last missing benchmark. Although fpc has a regexpr unit: http://svn.freepascal.org/svn/fpc/trunk/packages/base/regexpr/regexpr.pp It has many todos, such as adding support for | in the search expression. So this unit doesn't have enough functionality. Is somebody willing to invest time in this unit to complete it? An alternative could be to use the libc unit. But the fpc developers don't encourage its use and I cannot use it on windows, where I develop and improve the tests. Then there is also synregexpr.pas: http://svn.freepascal.org/svn/lazarus/trunk/components/synedit/synregexpr.pas But that is not distrubuted with fpc. And I don't know, if the license is open source. Is it looks likes a BSD derivative, but item 3, about income, doesn't seem to fit in. How should this benchmark be implemented?

How about using PCRE? I've used Delphi bindings before and they are quite nice. I guess it should compile with FPC out of the box.

This is the one I used: http://www.renatomancuso.com/software/dpcre/dpcre.htm

Cheers,
Krishna

I long to accomplish a great and noble task, but it is my chief duty to accomplish small tasks as if they were great and noble ! - Helen Keller
Marco van de Voort
to Пётр Косаревский
Show quoted text 8 lines
> Although fpc has a regexpr unit: > http://svn.freepascal.org/svn/fpc/trunk/packages/base/regexpr/regexpr.pp > It has many todos, such as adding support for | in the search expression. So this > unit doesn't have enough functionality. While '|' support is to be considered basic regex functionality, what is the really expected functionality? Basic seems to be: |()?*+ (non-UNICODE) support (from wikipedia).

| is not basic afaik. From re_format BSD Manpage:

Obsolete (``basic'') regular expressions differ in several respects. `|' is an ordinary character and there is no equivalent for its functional- ity. `+' and `?' are ordinary characters, and their functionality can be expressed using bounds (`{1,}' or `{0,1}' respectively). Also note that `x+' in modern REs is equivalent to `xx*'. The delimiters for bounds are `\{' and `\}', with `{' and `}' by themselves ordinary characters. The parentheses for nested subexpressions are `\(' and `\)', with `(' and `)' by themselves ordinary characters. `^' is an ordinary character except at the beginning of the RE or= the beginning of a parenthesized subex- pression, `$' is an ordinary character except at the end of the RE or= the end of a parenthesized subexpression, and `*' is an ordinary charac- ter if it appears at the beginning of the RE or the beginning of a paren- thesized subexpression (after a possible leading `^'). Finally, there is one new type of atom, a back reference: `\' followed by a non-zero deci- mal digit d matches the same sequence of characters matched by the dth parenthesized subexpression (numbering subexpressions by the positions of their opening parentheses, left to right), so that (e.g.) `\([bc]\)\1' matches `bb' or `cc' but not `bc'.

Пётр Косаревский
Show quoted text 21 lines
> Basic seems to be: |()?*+ (non-UNICODE) support (from wikipedia). | is not basic afaik. From re_format BSD Manpage: Obsolete (``basic'') regular expressions differ in several respects. `|' is an ordinary character and there is no equivalent for its functional- ity. `+' and `?' are ordinary characters, and their functionality can be expressed using bounds (`{1,}' or `{0,1}' respectively). Also note that `x+' in modern REs is equivalent to `xx*'. The delimiters for bounds are `\{' and `\}', with `{' and `}' by themselves ordinary characters. The parentheses for nested subexpressions are `\(' and `\)', with `(' and `)' by themselves ordinary characters. `^' is an ordinary character except at the beginning of the RE or= the beginning of a parenthesized subex- pression, `$' is an ordinary character except at the end of the RE or= the end of a parenthesized subexpression, and `*' is an ordinary charac- ter if it appears at the beginning of the RE or the beginning of a paren- thesized subexpression (after a possible leading `^'). Finally, there is one new type of atom, a back reference: `\' followed by a non-zero deci- mal digit d matches the same sequence of characters matched by the dth parenthesized subexpression (numbering subexpressions by the positions of their opening parentheses, left to right), so that (e.g.) `\([bc]\)\1' matches `bb' or `cc' but not `bc'.

You know the traditional Unix syntax, I quoted wikipedia's definition of "basic regex", and it looks like a simplified POSIX ERE (extended regular expression) syntax ( http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html ).

I've got the idea.

The "last missing benchmark" requires simplest bracket expressions like "[agt]" (equiv. to "(a|g|t)")). Bracketing is supported in FPC "regexpr" enough.

Also it requires substitution (find and replace all) of a regex in a string, which has nothing to do with regex standards.

Пётр Косаревский
Show quoted text 9 lines
Then there is also synregexpr.pas: http://svn.freepascal.org/svn/lazarus/trunk/components/synedit/synregexpr.pas But that is not distrubuted with fpc. And I don't know, if the license is open source. Is it looks likes a BSD derivative, but item 3, about income, doesn't seem to fit in. How should this benchmark be implemented? Vincent

What about contacting author of synregexpr and asking him to implement it?

He seems to live in the same city as me, so if the e-mail address is a dead-end (both web links are broken), I can try to contact him another way (and pursuade him to resolve this issue).

Vincent Snijders
to Пётр Косаревский
Пётр Косаревский wrote 12 lines
> Then there is also synregexpr.pas: > http://svn.freepascal.org/svn/lazarus/trunk/components/synedit/synregexpr.pas > But that is not distrubuted with fpc. And I don't know, if the license is open > source. Is it looks likes a BSD derivative, but item 3, about income, doesn't seem > to fit in. > > How should this benchmark be implemented? > What about contacting author of synregexpr and asking him to implement it? He seems to live in the same city as me, so if the e-mail address is a dead-end (both web links are broken), I can try to contact him another way (and pursuade him to resolve this issue).

I think synregexpr already implements it. The problem is, that synregexpr isn't distributed with fpc, so I cannot use it in the shootout.

Vincent