polyglot.ext.ibex.visit
Class Rewriter
java.lang.Object
polyglot.visit.NodeVisitor
polyglot.visit.HaltingVisitor
polyglot.visit.ErrorHandlingVisitor
polyglot.visit.ContextVisitor
polyglot.ext.ibex.visit.Rewriter
- All Implemented Interfaces:
- java.lang.Cloneable, Copy
- public class Rewriter
- extends ContextVisitor
Visitor which traverses the AST constructing type objects.
Method Summary |
protected void |
addGlrEof(MutableParserType pt,
GLR glr)
|
protected void |
addGlrMergeFunctions(MutableParserType pt,
GLR glr)
|
protected void |
addGlrSemanticActions(MutableParserType pt,
GLR glr)
|
protected void |
addGlrTableMembers(MutableParserType pt,
GLR glr)
|
protected NodeVisitor |
enterCall(Node parent,
Node n)
Replaces the functionality of the enter() method; all
sub-classes should over-ride this method instead of
enter() if there is any chance of exceptions being
generated. |
GLR |
glr()
|
IbexNodeFactory |
glrNodeFactory()
|
IbexTypeSystem |
glrTypeSystem()
|
protected Node |
leaveCall(Node old,
Node n,
NodeVisitor v)
Contains all of the functionality that can be done in the leave
method, but allows SemanticExceptions to be
thrown. |
protected Expr |
marshal(Expr e,
Type t,
ParserType pt)
|
protected Expr |
unmarshal(Expr e,
Type t,
ParserType pt)
|
protected void |
unmarshalSvals(RhsCase rhs,
Expr sval,
java.util.List code,
java.util.List args,
MutableParserType pt)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Rewriter
public Rewriter(Job job,
TypeSystem ts,
NodeFactory nf)
glrTypeSystem
public IbexTypeSystem glrTypeSystem()
glrNodeFactory
public IbexNodeFactory glrNodeFactory()
enterCall
protected NodeVisitor enterCall(Node parent,
Node n)
throws SemanticException
- Description copied from class:
ErrorHandlingVisitor
- Replaces the functionality of the
enter()
method; all
sub-classes should over-ride this method instead of
enter()
if there is any chance of exceptions being
generated.
This method is the replacement for the enter()
method,
so that all of its subclasses gain the error handling capabilities
of this visitor without having to rewrite it for the
enter()
for each sub-class.
This method allows for a SemanticException
to be
thrown in the body, while enter()
does not.
- Overrides:
enterCall
in class ErrorHandlingVisitor
- Parameters:
n
- The root of the subtree to be traversed.
- Returns:
- The
ErrorHandlingVisitor
which should be
used to visit the children of n
.
- Throws:
SemanticException
- See Also:
NodeVisitor.enter(Node, Node)
leaveCall
protected Node leaveCall(Node old,
Node n,
NodeVisitor v)
throws SemanticException
- Description copied from class:
ErrorHandlingVisitor
- Contains all of the functionality that can be done in the
leave
method, but allows SemanticExceptions
to be
thrown.
This method is in addition to the leave
method,
and allows the compiler writer to write code that can throw errors
and let the polyglot infrastructure handle the exceptions.
- Overrides:
leaveCall
in class ErrorHandlingVisitor
- Parameters:
old
- The original state of root of the current subtree.n
- The current state of the root of the current subtree.v
- The NodeVisitor
object used to visit the children.
- Returns:
- The final result of the traversal of the tree rooted at
n
.
- Throws:
SemanticException
- See Also:
NodeVisitor.leave(Node, Node, NodeVisitor)
glr
public GLR glr()
addGlrMergeFunctions
protected void addGlrMergeFunctions(MutableParserType pt,
GLR glr)
throws SemanticException
- Throws:
SemanticException
unmarshalSvals
protected void unmarshalSvals(RhsCase rhs,
Expr sval,
java.util.List code,
java.util.List args,
MutableParserType pt)
unmarshal
protected Expr unmarshal(Expr e,
Type t,
ParserType pt)
marshal
protected Expr marshal(Expr e,
Type t,
ParserType pt)
addGlrSemanticActions
protected void addGlrSemanticActions(MutableParserType pt,
GLR glr)
throws SemanticException
- Throws:
SemanticException
addGlrTableMembers
protected void addGlrTableMembers(MutableParserType pt,
GLR glr)
throws SemanticException
- Throws:
SemanticException
addGlrEof
protected void addGlrEof(MutableParserType pt,
GLR glr)
throws SemanticException
- Throws:
SemanticException