Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:nil arch:headline
#+OPTIONS: author:t c:nil creator:nil d:(not "LOGBOOK") date:t e:t
#+OPTIONS: email:nil f:t inline:t num:t p:nil pri:nil prop:nil stat:t
#+OPTIONS: tags:t tasks:t tex:t timestamp:t title:t toc:t todo:t |:t
#+TITLE: MetaII
#+DATE: <2016-01-16 Sat>
#+AUTHOR: Raimon Grau
#+EMAIL: raimonster@gmail.com
#+LANGUAGE: en
#+SELECT_TAGS: export
#+EXCLUDE_TAGS: noexport
#+CREATOR: Emacs 24.5.1 (Org mode 8.3.2)

[[./img/penrose.gif]]

* What
  This is my implementation of Schorre's [[http://www.ibm-1401.info/Meta-II-schorre.pdf][metaII]] metacompiler using
  perl5 regex's for bootstrapping and compiling to lua (using
  http://loup-vaillant.fr/projects/metacompilers lua's model).
  Articles abut the implementation and random ramblings also in [[http://puntoblogspot.blogspot.com.es/search/label/metacompilers][my
  blog]].

* Why
  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 [[http://perldoc.perl.org/perlre.html][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
  (?{}).

* Why should I care?
  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.

* Curious to note from the code:

** Recursive regexes in perl can call themselves.
   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.

** /x flag in regex is invaluable in this case.

** Perldoc
   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 [[http://perldoc.perl.org/perlre.html#Backtracking][Backtracking]] to see a great explanation of
   backtracking behaviour in regexes.

** Special vars in Perl regexen.
   $[1-9] get reset after a complete regex has ben matched, but not
   during the matching. If you need to match the latest match in this
   very same regex, use $^N.  Use a stack in case of nested regexes
   needing the 'latest match'. More regex wizardy in "Parsing JSON with
   a single regex": https://www.youtube.com/watch?v=-O-Uajd2WzU

* See also
  - [[http://www.tinlizzie.org/ometa/][Ometa]]
  - http://home.pipeline.com/~hbaker1/Prag-Parse.html
  - https://queue.acm.org/detail.cfm?id=2724586
  - http://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)

* Who
  - Author: Raimon Grau <raimonster@gmail.com>
  - Gif artwork: https://www.reddit.com/r/perfectloops/comments/413wxr/penrose_loop/

About

Implementation of bootstrapped metaII metacompiler using perl 5 regex

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages