On Mon, Jul 14, 2014 at 3:19 PM, Artur Skawina via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > On 07/14/14 13:42, Philippe Sigaud via Digitalmars-d-learn wrote: >> asserts get an entire copy of the parse tree. It's a bit wasteful, but >> using 'immutable' directly does not work here, but this is OK: >> >> enum res = MyRegex("abcabcdefFOOBAR"); // compile-time parsing >> immutable result = res; // to avoid copying the enum value everywhere > > static immutable result = MyRegex("abcabcdefFOOBAR"); // compile-time > parsing
Ah, static! > >> The static asserts then works (not the toString, though). Maybe (snip diff) I'll push that to the repo, thanks! I should sprinkle some const and pure everywhere... > [completely untested; just did a git clone and fixed the two > errors the compiler was whining about. Hmm, did pegged get > faster? Last time i tried (years ago) it was unusably slow; > right now, compiling your example, i didn't notice the extra > multi-second delay that was there then.] It's still slower than some handcrafted parsers. At some time, I could get it on par with std.regex (between 1.3 and 1.8 times slower), but that meant losing some other properties. I have other parsing engines partially implemented, with either a larger specter of grammars or better speed (but not both!). I hope the coming holidays will let me go back to it.