Random notes about pluggable perl parser backends

rafael on 2002-08-02T07:33:29

This idea took shape this night, while I was sleeping. It's about allowing to plug parser backends into the very perl interpreter. I'm writing it down here because I will not have time to work on it before my vacation. It's simple :

  • Compile a perl with some option -DPARSER_PLUGINS to get the support code, which will, hopefully, be simple and short
  • The parser plugin is in some module Perl5::Parser::Foo -- one sub per grammar rule
  • There's a new pragma use parser qw(Foo) that loads and enables this parser plugin -- it sets $^H{parser} to "Perl5::Parser::Foo" (as it uses %^H it has block-scoped semantics)
  • Each time the yacc parser reduces, it checks $^H{parser} for existence -- if it's here, it calls the corresponding method on it.
KISS.