There was a prior question about golfing an HQ9+ compiler that translates HQ9+ code into the language it is written in, but that was closed as a duplicate of the interpreter challenge because converting an interpreter to a compiler is seen as trivial. This question is based on the closed one, but has some changes.
Write an HQ9+ transpiler in a language of your choice. Your submission should be written in some language X, and should take input of HQ9+ source and output a program in another language Y.
H command prints
Q outputs the program's code. For this challenge, it must print the transpiled code, not the HQ9+ source, and must not use cheating quine methods. This deviates from the HQ9+ "specification," but is intended to further distinguish this challenge from the interpreter one. For the avoidance of doubt, using
function.toString() are not considered cheating for the purpose of this challenge.
9 command prints the lyrics to "99 Bottles of Beer." You may use any reasonable variant of the lyrics.
+ increments the accumulator. However, because the accumulator cannot be addressed,
+ is effectively a no-op.
9 may, but are not required to, print trailing newlines.
+ must not produce any output, not even whitespace.
Input must be case-insensitive;
HQ are the same program. Behavior with unrecognized characters is undefined.
- Language X should satisfy the traditional definition of a language
- Standard loopholes disallowed
- Your solution must be testable
- Y cannot be HQ9+ or an extension of HQ9+
- Score is calculated as length of transpiler, plus length of output for
H, plus length of output for
Q, plus length of output for
9, plus length of output for
+, plus length of output for