sjm.parse
Class Assembler
java.lang.Object
|
+--sjm.parse.Assembler
- Direct Known Subclasses:
- MacroArgAssembler, MacroBodyAssembler, MacroCallAssembler, MacroElseAssembler, MacroEndifAssembler, MacroExpandAssembler, MacroHeaderAssembler, MacroIfdefAssembler, MacroIncludeAssembler, MacroUndefAssembler, TerminalAssembler
- public abstract class Assembler
- extends java.lang.Object
Parsers that have an Assembler ask it to work on an
assembly after a successful match.
By default, terminals push their matches on a assembly's
stack after a successful match.
Parsers recognize text, and assemblers provide any
sort of work that should occur after this recognition.
This work usually has to do with the state of the assembly,
which is why assemblies have a stack and a target.
Essentially, parsers trade advancement on a assembly
for work on the assembly's stack or target.
- Version:
- 1.0
- Author:
- Steven J. Metsker
Method Summary |
static java.util.Vector |
elementsAbove(Assembly a,
java.lang.Object fence)
Returns a vector of the elements on an assembly's stack
that appear before a specified fence.
|
abstract void |
workOn(Assembly a)
This is the one method all subclasses must implement. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Assembler
public Assembler()
elementsAbove
public static java.util.Vector elementsAbove(Assembly a,
java.lang.Object fence)
- Returns a vector of the elements on an assembly's stack
that appear before a specified fence.
Sometimes a parser will recognize a list from within
a pair of parentheses or brackets. The parser can mark
the beginning of the list with a fence, and then retrieve
all the items that come after the fence with this method.
- Parameters:
assembly
- a assembly whose stack should contain
some number of items above a fence markerobject
- the fence, a marker of where to stop
popping the stack- Returns:
- Vector the elements above the specified fence
workOn
public abstract void workOn(Assembly a)
- This is the one method all subclasses must implement. It
specifies what to do when a parser successfully
matches against a assembly.
- Parameters:
Assembly
- the assembly to work on