Finally I have some time to work on the FrameMaker::Mif project again. To paraphrase Spock, I am trying to build a LL(1) parser with stone knives and bearskins.
- The first time I tried writing the MIF parser, I used the Parse::RecDescent module. Unfortunately, when I encountered bugs -- I don't know whether they were my bugs or the module author's -- I had trouble debugging it, because the data structures that Parse::RecDescent produces are large, hairy, and contain code references (which Data::Dumper doesn't print out).
- Then I wrote a yacc grammar and used the -P (if memory serves) switch on byacc to generate a y.tab.pl file. I got a bare-bones module working with that technique, but now I want to change the data structure that the parser generates, and since I am a Prisoner of Bill here, schlepping files to and from a Unix account every time I want to tweak the grammar is not my idea of a good time.
- Then I thought, aha, Perl now ships with all these funky XML modules -- I can just translate the MIF file into an XML-syntax file that has exactly the same abstract structure, and use the XML modules to read the file back in and play with it. This is beginning to look like more trouble than it's worth.
- So, I've been boning up on the Tiger Book, writing up grammars, and then working out the FIRST and FOLLOW sets. Eleven terminals, ten nonterminals, nineteen productions, nothing but paper 'n ink. (I oughtta be a good boy and write a script to check my math before I actually implement this thing, right?) If I code this and it works, then I'll probably just download Parse::RecDescent again and use it. If it doesn't work, at least I'll have a better chance of knowing why....