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 thinking about this problem?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.