Output Generation

Emitting the code is the simplest of all phases. Since Parrot requires all the variables to be declared, a comma separated string $dec is built concatenating the keys of the symbol table hash %s. The code is then indented and the different components are articulated through a HERE document:
    sub output_code {
      my ($trans, $dec) = @_;

      # Indent
      $$trans =~ s/^/\t/gm;

      # Output the code
    print << "TRANSLATION";
    .sub 'main' :main
    \t.local num $$dec
    $$trans
    .end
    TRANSLATION
The call to output_code finishes the job:
    output_code(\$t->{trans}, \$dec);



Procesadores de Lenguajes 2010-01-31