NAME ^

HLLCompiler - base class for compiler objects

DESCRIPTION ^

This file implements a HLLCompiler class of objects used for creating HLL compilers. It provides the standard methods required for all compilers, as well as some standard scaffolding for running compilers from a command line.

Methods ^

attr(string attrname, pmc value, int has_value)

Helper method for accessors -- gets/sets an attribute given by attrname based on has_value.

language(string name)

Register this object as the compiler for name using the compreg opcode.

parsegrammar([string grammar])

Accessor for the parsegrammar attribute.

astgrammar([string grammar])

Accessor for the astgrammar attribute.

compile(pmc code [, "option" => value, ... ])

Compile source (possibly modified by any provided options). If a compsub has been registered for this compiler, use it, otherwise use the parsegrammar and astgrammar attributes to get to an AST and compile it, otherwise throw an exception.

parse(source [, "option" => value, ...])

Parse source using the compiler's parsegrammar according to any options and return the resulting parse tree.

ast(source [, "option" => value, ...])

Transform source into an AST using the compiler's astgrammar according to any options, and return the resulting ast.

eval(code [, "option" => value, ...])

Compile and execute the given code taking into account any options provided.

interactive(["encoding" => encoding] [, "option" => value, ...])

Runs an interactive compilation session -- reads lines of input from the standard input and evaluates each. The encoding option specifies the encoding to use for the input (e.g., "utf8").

evalfiles(files [, args] [, "encoding" => encoding] [, "option" => value, ...])

Compile and evaluate a file or files. The files argument may be either a single filename or an array of files to be processed as a single compilation unit. The encoding option specifies the encoding to use when reading the files, and any remaining options are passed to the evaluator.

command_line(PMC args)

Generic method for compilers invoked from a shell command line.

parse_name(string name)

Split name into its component namespace parts, as required by pdd21. The default is simply to split the name based on double-colon separators.

register(string name, pmc compsub) # DEPRECATED

(Deprecated.) Registers this compiler object as name and using compsub as the subroutine to call for performing compilation.

AUTHOR ^

Patrick R. Michaud <pmichaud@pobox.com>


parrot