HLLCompiler - base class for compiler objects
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.
- attr(string attrname,
pmc value,
int has_value)
- Helper method for accessors -- gets/sets an attribute given by attrnamebased onhas_value.
- language(string name)
- Register this object as the compiler for nameusing thecompregopcode.
- parsegrammar([string grammar])
- Accessor for the parsegrammarattribute.
- astgrammar([string grammar])
- Accessor for the astgrammarattribute.
- ostgrammar([string grammar])
- Accessor for the 'ostgrammar' attribute.
- 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).
If a compsub has been registered for this compiler,
use it,
otherwise use theparsegrammarandastgrammarattributes to get to an AST and compile it,
otherwise throw an exception.
- parse(source [,
"option" => value,
...])
- Parse sourceusing the compiler'sparsegrammaraccording to any options and return the resulting parse tree.
- ast(source [,
"option" => value,
...])
- Transform sourceinto an AST using the compiler'sastgrammaraccording to any options,
and return the resulting ast.
- eval(code [,
"option" => value,
...])
- Compile and execute the given codetaking 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 encodingoption 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 filesargument may be either a single filename or an array of files to be processed as a single compilation unit.
Theencodingoption 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 nameinto its component namespace parts,
as required by pdd21.
The default is simply to split the name based on double-colon separators.
- ost(source [,
adverbs :slurpy :named])
- Transform sourceusing the compiler'sostgrammaraccording to any options given byadverbs,
and return the resulting ost.
- register(string name,
pmc compsub) # DEPRECATED
- (Deprecated.) Registers this compiler object as nameand usingcompsubas the subroutine to call for performing compilation.
Patrick R.
Michaud <pmichaud@pobox.com>