my $filename = shift;
my $parser = Infix->new();
# read input
$parser->slurp_file($filename);
# lexical and syntax analysis
my $t = $parser->YYParse();
# tree transformations:
# machine independent optimizations
$t->s(our @algebra);
# Address Assignment
our $reg_assign;
$reg_assign->s($t);
# Translate to PARROT
$t->bud(our @translation);
# variable declarations
my $dec = build_dec();
peephole_optimization($t->{tr});
output_code(\$t->{tr}, \$dec);
The compiler uses the parser for infix expressions that was generated from the Eyapp grammar Infix.eyp (see section 5) using the command:
$ eyapp Infix.eyp $ ls -tr | tail -1 Infix.pmIt also uses the module containing different families of tree transformations that are described in the I2PIR.trg file (explained in sections 6 and 8):
$ treereg -m main I2PIR.trg $ ls -tr | tail -1 I2PIR.pm $ head -1 I2PIR.pm package main;The option
-m main tells treereg
to place the generated tree transformations inside the main
namespace. Is in this file that the variables
@algebra, @translation and
$reg_assign used during the machine-independent optimization,
code generation and register allocation phases are defined.
Procesadores de Lenguajes 2010-01-31