Matt S Trout > Rakudo-Star-2012.08_001 > PCT::HLLCompiler

Download:
Rakudo-Star-2012.08_001.tar.gz

Annotate this POD

Source  

NAME ^

PCT::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.

panic(message :slurpy)

Helper method to throw an exception (with a message).

language(string name)

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

stages([stages])

Accessor for the stages attribute.

parsegrammar([string grammar])

Accessor for the parsegrammar attribute.

parseactions([actions])

Accessor for the parseactions attribute.

astgrammar([grammar])

Accessor for the astgrammar attribute.

commandline_banner([string value])

Set the command-line banner for this compiler to value. The banner is displayed at the beginning of interactive mode.

commandline_prompt([string value])

Set the command-line prompt for this compiler to value. The prompt is displayed in interactive mode at each point where the compiler is ready for code to be compiled and executed.

compiler_progname([string name])

Accessor for the compiler_progname, which is often the filename of the compiler's program entry point, like perl6.pbc.

removestage(string stagename)

Delete a stage from the compilation process queue.

addstage(string stagename [, "option" => value, ... ])

Add a stage to the compilation process queue. Takes either a "before" or "after" named argument, which gives the relative ordering of the stage to be added. If "before" and "after" aren't specified, the new stage is inserted at the end of the queue.

It's possible to add multiple stages of the same name: for example, you might repeat a stage like "optimize_tree" or "display_benchmarks" after each transformation. If you have multiple stages of the same name, and add a new stage before or after that repeated stage, the new stage will be added at every instance of the repeated stage.

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

Compile source (possibly modified by any provided options) by iterating through any stages identified for this compiler. If a target option is provided, then halt the iteration when the stage corresponding to target has been reached.

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

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

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

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

post(source [, adverbs :slurpy :named])

Transform PAST source into POST.

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").

EXPORTALL(source, destination)

Export all namespace entries from the default export namespace for source (source::EXPORT::ALL) to the destination namespace.

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.

process_args(PMC args)

Performs option processing of command-line args

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.

lineof(target, pos [, cache :named('cache')])

Return the line number of offset pos within target. The return value uses zero for the first line. If cache is true, then memoize the line offsets as a !lineof property on target.

dumper(obj, name, options)

Dump obj with name according to options.

usage()

A usage method.

version()

Display compiler version information.

AUTHOR ^

Patrick R. Michaud <pmichaud@pobox.com>

syntax highlighting: