More Yacc to Parrot translation

ChrisDolan on 2008-07-23T06:02:27

I mentioned a while back that I was playing with a PCT-based grammar to parse Yacc files and transcode the Yacc grammar to PCT.

My project took two big detours.

First, I re-learned that Yacc is a parser for a pre-tokenized stream and does not include lexing or scanning, unlike PCT. So it is infeasible to do a full, automated translation. I suspected that would be the case when I started, but I didn't realize how far from complete my translation would be. Basically, I generate a lot of mostly-useful PGE "rule {}" constructs, but then a lot of placeholder "token {}" constructs that need to be addressed by a human.

The second detour was that I was trying to learn Yacc and PCT/PGE at the same time, which was too much. So, I dropped down to Perl5 and wrote a parser based on the m/\G.../cgxms construct. The good news is that I finished, and the parser is blazing fast, if verbose. I can parse the whole Yacc vocabulary (well, Bison v2.1 really). My testcases are perl/perly.y, bash/parse.y, cola.y, lua51.y and even bison/parse-gram.y. I am generating PCT grammar.pg and actions.pm files that actually compile, but they are far from functional -- they're just starting points, really, but they're better than a blank page I think.

So, opinions are welcome:

  • Should I continue working on the Perl5 parser to get it to make better PCT output?
  • Should I work on porting the parser itself to PCT?
  • Should I put this aside and start using it to make real Parrot code from existing Yacc grammars?
  • Or should I work on the RT/CPANTesters bugs that have been accumulating against my existing packages? Sigh...