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=parse [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 (src/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()
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.
|