| parrotcode: APL compiler/interpreter | |
| Contents | Language Implementations | APL |

APL -- APL compiler/interpreter

Run from the command line:
$ parrot APL.pbc file.apl # execute stmts in file.apl
$ parrot APL.pbc # interactive mode
$ parrot APL.pbc --target=paarse [file.apl] # display parse tree
$ parrot APL.pbc --target=PAST [file.apl] # display AST
Run from another Parrot program:
.sub main :main
# load the compiler
load_bytecode 'APL.pbc'
# get the compiler
.local pmc apl
apl = compreg 'APL'
# APL source code
source = unicode:"FOOâ1 2"
# compile source
$P0 = apl(source)
# execute code
$P0()
# other compile options:
$P0 = apl(source, target=>'parse') # get parse tree
$P0 = apl(source, target=>'PAST') # get abstract syn tree
$P0 = apl(source, target=>'PIR') # get PIR code
.end

APL.pbc is an interpreter for the APL language. Its parser is implemented using a PGE grammar (lib/APLGrammar.pg), and compilation is performed as a TGE tree transformation from the match object returned by the grammar into an abstract syntax tree. Then the abstract syntax tree is converted to PIR code, and the PIR code is compiled to return an executable Eval PMC.


__onload()compile(STR code [, 'target' = target])>code. The target named parameter allows the caller to specify the degree of compilation to be performed; a value of parse returns the parse tree, PAST returns the abstract syntax tree, PIR returns the generated PIR code, and all other values cause the program or statements to be executed.main(PMC args)
Copyright (C) 2006, The Perl Foundation.
This is free software; you may redistribute it and/or modify it under the same terms as Parrot.
|
|
|