More on the shadow parser

rafael on 2002-07-30T07:10:31

I worked a bit more on my Perl5::ShadowParser (see this previous entry). I shaped it into a module, with the ability to plug backends in. Backends are modules with a list of methods rule1..rule197 to be triggered by the parser's reduce actions (just like any other LALR parser -- there's precisely 195 grammar rules as of perl 5.8.0) and (here comes the difficult part) a token method to be called each time a token is read. I have to add a constructor as well.

Yes, that's the main difficulty : the tokenizer. I can't always figure out the value of the token returned to the parser (the one declared with %token in the yacc source) or the contents of the input source associated to each non-faked-up token. (The tokenizer sometimes makes up tokens to help the parser. Or it may switch two tokens. I suspect it to cast a spell from time to time.)

OK, if this approach doesn't work, I'll try plan B: patch perl to allow pluggable parser backends.

If strain on the lexer were a design criterion, I blew it long ago. -- Larry Wall
And I should avoid sausage factories.