Friday afternoon blag fest
publiustemp-londonpm at yahoo.com
Fri Sep 21 16:03:46 BST 2007
--- Dave Hodgkinson <davehodg at gmail.com> wrote:
> > I believe mine is 5214 characters, but it appears to very fast when
> > run
> > against its intended target text.
> There's enough repetition in there that it should be templated and
> iterated over.
I should have explained the context. It's actually for AI::Prolog and
the core parser doesn't understand Prolog math. Rather than extend
(and possibly break) a working parser, I wrote a preprocessor which
turns things like this:
X \= 9 / (3 + (4+7) % ModValue) + 2 / (3+7).
Into things like this (whitespace added for alleged clarity):
div(9, mod(plus(3, plus(4, 7)), ModValue)),
div(2, plus(3, 7))
However, the regex is definitely built programmatically. The final
regex is built like this:
my $expression = qr/
I would never dream of writing a regex that huge by hand.
Buy the book - http://www.oreilly.com/catalog/perlhks/
Perl and CGI - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog - http://use.perl.org/~Ovid/journal/
More information about the london.pm