[ruby-announce] regexp-engine v0.2

Simon Strandgaard <[email protected]> Thu, 13 Nov 2003 12:39:35 +0100
Newsgroups gmane.comp.lang.ruby.announce
Message-ID <[email protected]>
I am proud to present version 0.2 of my regexp-engine,
it takes up only 785 lines of Ruby code and can do the most=20
fundemental operations. In my opinion its good OO.

Please feel free to ask me questions.

download:
http://rubyforge.org/download.php/200/regexp-engine-0.2.tar.gz

this projects RAA entry:
http://raa.ruby-lang.org/list.rhtml?name=3Dregexp

browse CVS:
http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/projects/regexp_engine=
/source/?cvsroot=3Daeditor






Regular Expressions engine, a subproject of AEditor
2003, Copyright by Simon Strandgaard
http://aeditor.rubyforge.org/



About
=3D=3D=3D=3D=3D

AEditor needs a regexp engine. You probably think, why not
rely on an existing engine (for instance Ruby's regexp engine) ?
Existing engines are not flexible enough. The iterator pattern=20
provides that needed flexibility. Thus it should not matter
wheter the engine operate on: UCS-4 or UTF-8 or ASCII.

Goal is to build an engine which is fully compatible with Ruby's=20
regexp syntax, which can work with iterators.

Eventualy extend the regexp syntax, with some editor-stuff.
For instance: point where cursor should be placed,
match text which is legal ruby code, execute regexp within
retangular selection... etc. I am open to other suggestions.

Eventualy re-implement in C++ to gain performance.


Status
=3D=3D=3D=3D=3D=3D

Data structure has stabilized and the fundemental operations=20
are working quite good (was difficult to implement).
Iterators is not yet implemented, thus only ASCII right now.
Performance is not impressive.
Left is all the easy stuff.

* features of the scanner so far:
  a|b|c      alternation=20
  *          repeat(0..infinity) greedy
  +          repeat(1..infinity) greedy
  {n,}       repeat(n..infinity) greedy
  ( ... )    grouping -> register.. nested repeat also works

* features of the parser so far:
  ( ... )    group -> register
  |          alternation
  \1 .. \9   backreferences
  \          escape
  .          match anything except newline
  *          repeat(0..infinity) greedy=20
  *?         repeat(0..infinity) lazy=20
  +          repeat(1..infinity) greedy=20=20
  +?         repeat(1..infinity) lazy=20=20
  {n,m}      repeat(n..m) greedy constraint(n <=3D m)
  {n,m}?     repeat(n..m) lazy   constraint(n <=3D m)
  {n,}       repeat(n..infinity) greedy
  {n,}?      repeat(n..infinity) lazy
  {m}        repeat(m..m) greedy
  {m}?       repeat(m..m) lazy         Does this one make sense ?
  specialcase: illegal ranges is treated as they are just=20
  ordinary literals.


License
=3D=3D=3D=3D=3D=3D=3D

Ruby's license.


Comments
=3D=3D=3D=3D=3D=3D=3D=3D

I hope you like it.

--
Simon Strandgaard