What are the steps involved in writing a Perl Code Generator in Haskell?
Given that Perl 5 does not conform to BNF, I'm at a loss as to how to think about this problem. Could someone offer some advice to set me off in the right way 开发者_如何学JAVAthinking about this problem?
Depends on what you want to generate.
If the Perl code you wish to generate does conform to a BNF, then you clearly think (rightly) that there's a solution: build a tree corresponding to Perl fragment, and then prettyprint the tree. This will only be an issue if you insist on generating the same syntax, which can be ambiguously interpreted by Perl.
You can also simply use text templates for the Perl code and fill in the slots. If you code generator doesn't have to compose the pieces in complicated ways, this will work fine, too.
精彩评论