in reply to Re: Perl 6 rules and complexity
in thread Perl 6 rules and complexity
Yeah, it depends on the grammar but worst case is exponential (according to this guy anyway). If it's memoizable it's guaranteed to be linear in the length of the string being parsed (worst case is @rules * length($string) ). This only includes a very limited type of backtracking, once you allow more powerful regex-like backtracking on quantified rules it becomes very easy to lose linearity even with memoization.
It would be unfortunate if people could write programs that didn't either compile or fail in a reasonable time or if people took 2 pieces of code that independently compiled quickly but when appended compiled much more slowly.
The ability to cause arbitrary side-effects in rule actions makes that far easier to do or possibly even guarantees it for anything but the simplest grammars (for example any grammar that is an extension of Perl6's).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl 6 rules and complexity
by zby (Vicar) on Feb 18, 2006 at 09:42 UTC | |
by fergal (Chaplain) on Feb 18, 2006 at 13:07 UTC | |
by zby (Vicar) on Feb 18, 2006 at 16:41 UTC |