A more proper explanation is that "generated g-code" should be replaced with "stored g-code" as no generation is being done... you are simply doing a one-for-one output.
So, IF you speak "A" the return match may be pointer "0" and "B" may return pointer "1" ...
Essentially this is nothing more than a switch-case control:
switch...case - Arduino Reference
Just be certain to store your serial.Print g-code stream using the "F-macro" .
Serial.print(F(“Hello World”)); - Using Arduino / Programming Questions - Arduino Forum
The obvious ramifications to the above are 1) you are going to use serial to connect to the second Arduino, 2) the BAUD and other serial parameters much match what the second Arduino expects, and 3) you must manage all preambles and closing control statements in your g-stream program.