NAME ^

APL -- APL compiler/interpreter

SYNOPSIS ^

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

Description ^

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.

Functions ^

APL Namespace ^

__onload()

Initializes the compiling subsystem.

compile(STR code [, 'target' = target])>

Compile the APL program given by 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)

Handles program control when the AST.pbc file is executed directly from the Parrot command line. It calls all of the submodule :load routines, then processes commands from the file specified on the command line or standard input.

The --target= command line option allows the compilation to display a parse tree or abstract syntax tree in lieu of executing program statements.

LICENSE ^

Copyright (C) 2006, The Perl Foundation.

This is free software; you may redistribute it and/or modify it under the same terms as Parrot.


parrot