This is my implementation of Schorre’s metaII metacompiler using perl5 regex’s for bootstrapping and compiling to lua (using https://loup-vaillant.fr/projects/metacompilers lua’s model). Articles abut the implementation and random ramblings also in my blog.
Reading about metacompilers I’ve tinkered with them on and off for a couple of months, taking off from loup’s implementation, but when I was reading perlre, I rediscovered the (?{}) extended pattern, which basically does the same as metaII ouptut patterns, so I tried to bootstrap a metaII compiler using recursive regular expressions and (?{}).
Take a look at ./bootstrap.txt , and if you don’t find that a piece of self-reference beauty, you probably shouldn’t care at all.
Or call undefined regexes at compile time: Instead of directly calling them by name, you have to wrap them into (??{our $regex}) to delay the evaluation to runtime.
Perl has by far the best documentation I’ve read for any programming language. Fun to read, useful and pragmatic at the same time. Take a look at Backtracking to see a great explanation of backtracking behaviour in regexes.
- Ometa
- https://home.pipeline.com/~hbaker1/Prag-Parse.html
- https://queue.acm.org/detail.cfm?id=2724586
- https://www.bayfronttechnologies.com/mc_tutorial.html
- https://news.ycombinator.com/item?id=38184366 (https://github.com/kragen/stoneknifeforth and https://github.com/kragen/peg-bootstrap/blob/master/peg.md)
- Author: Raimon Grau <[email protected]>
- Gif artwork: https://www.reddit.com/r/perfectloops/comments/413wxr/penrose_loop/