|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.singularsys.jep.NodeFactory
com.singularsys.jep.misc.lineNumbering.LineNumberingNodeFactory
public class LineNumberingNodeFactory
A NodeFactory which adds line numbering information to nodes.
The method setCurrentPosition(int,int) is used to set the position before calling one of the
buildConstantNode(Object value) methods.
This stores the line and column numbers in the created node using the
Node.setHook(Node.HookKey,Object) method.
The getLineNumber(Node) and getColumn(Node) class methods can be used to retrieve
this information from a given node.
By convention, numbering starts from line 1 column 1.
| Nested Class Summary | |
|---|---|
static class |
LineNumberingNodeFactory.Numbering
|
| Field Summary |
|---|
| Fields inherited from class com.singularsys.jep.NodeFactory |
|---|
ev, j, vt |
| Constructor Summary | |
|---|---|
LineNumberingNodeFactory()
Default constructor which decorates a NodeFactory. |
|
LineNumberingNodeFactory(NodeFactory root)
Decorating constructor |
|
| Method Summary | |
|---|---|
ASTConstant |
buildConstantNode(ASTConstant node)
Create an ASTConstant with same value as argument |
ASTConstant |
buildConstantNode(java.lang.Object value)
Creates an ASTConstant node with specified value. |
ASTConstant |
buildConstantNode(Operator op,
Node child1)
Creates a ASTConstant whose value of applying a unary operator to its arguments. |
ASTConstant |
buildConstantNode(Operator op,
Node[] children)
Creates a ASTConstant whose value of applying the operator to its arguments. |
ASTConstant |
buildConstantNode(Operator op,
Node child1,
Node child2)
Creates a ASTConstant whose value of applying binary operator to its arguments. |
ASTConstant |
buildConstantNode(PostfixMathCommandI pfmc,
Node[] children)
Creates a constant node whose result is the given function applied to the children. |
ASTFunNode |
buildFunctionNode(ASTFunNode node,
Node[] arguments)
Builds a function with n arguments and same fun as specified in arguments. |
ASTFunNode |
buildFunctionNode(java.lang.String name,
PostfixMathCommandI pfmc,
Node[] arguments)
Builds a function with n arguments This method should be sub-classed |
ASTOpNode |
buildOperatorNode(Operator op,
Node child)
creates a unary function. |
ASTOpNode |
buildOperatorNode(Operator op,
Node[] arguments)
Builds a operator node with n arguments This method should be sub-classed |
ASTOpNode |
buildOperatorNode(Operator op,
Node lhs,
Node rhs)
creates a binary function. |
ASTOpNode |
buildUnfinishedOperatorNode(Operator op)
An unfinished node. |
ASTVarNode |
buildVariableNode(ASTVarNode node)
creates a new ASTVarNode with the same name as argument. |
ASTVarNode |
buildVariableNode(java.lang.String name)
Build a variable node when just the name is known. |
ASTVarNode |
buildVariableNode(Variable var)
creates a new ASTVarNode with a given variable. |
ASTVarNode |
buildVariableNodeCheckUndeclared(java.lang.String name)
Build a variable node checking for the undeclared status. |
static int |
getColumn(Node node)
Convenience method to get the column number of a node. |
int |
getCurrentColumn()
Gets the current column used when a node is created. |
int |
getCurrentLine()
Gets the current line used when a node is created. |
JepComponent |
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads. |
static int |
getLineNumber(Node node)
Convenience method to get the line number of a node. |
NodeFactory |
getRoot()
|
void |
init(Jep jep)
Initialize the component. |
void |
setCurrentPosition(int line,
int col)
Sets the current position which will be used the next time a node is created. |
static void |
setPosition(Node node,
int line,
int col)
Convenience method to set the line and column numbers for a node. |
| Methods inherited from class com.singularsys.jep.NodeFactory |
|---|
copyChildren |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LineNumberingNodeFactory(NodeFactory root)
root - public LineNumberingNodeFactory()
| Method Detail |
|---|
public static int getLineNumber(Node node)
node -
public static int getColumn(Node node)
node -
public static void setPosition(Node node,
int line,
int col)
node - who's position will be setline - line numbercol - column number
public void setCurrentPosition(int line,
int col)
line - col - public int getCurrentLine()
public int getCurrentColumn()
public ASTConstant buildConstantNode(ASTConstant node)
throws ParseException
NodeFactory
buildConstantNode in class NodeFactoryParseException
public ASTConstant buildConstantNode(java.lang.Object value)
throws ParseException
NodeFactory
buildConstantNode in class NodeFactoryParseException
public ASTConstant buildConstantNode(Operator op,
Node child1,
Node child2)
throws ParseException
NodeFactory
buildConstantNode in class NodeFactoryParseException
public ASTConstant buildConstantNode(Operator op,
Node child1)
throws ParseException
NodeFactory
buildConstantNode in class NodeFactoryParseException
public ASTConstant buildConstantNode(Operator op,
Node[] children)
throws ParseException
NodeFactory
buildConstantNode in class NodeFactoryParseException
public ASTConstant buildConstantNode(PostfixMathCommandI pfmc,
Node[] children)
throws ParseException
NodeFactory
buildConstantNode in class NodeFactorypfmc - the function to applychildren - the arguments to the function, each argument should be a constant node.
ParseException
public ASTFunNode buildFunctionNode(ASTFunNode node,
Node[] arguments)
throws ParseException
NodeFactory
buildFunctionNode in class NodeFactorynode - the properties (name and pfmc) of this node will be copied.arguments - the arguments to the function.
ParseException
public ASTFunNode buildFunctionNode(java.lang.String name,
PostfixMathCommandI pfmc,
Node[] arguments)
throws ParseException
NodeFactory
buildFunctionNode in class NodeFactoryname - of function.pfmc - PostfixMathCommand for function.arguments - the arguments to the function.
ParseException
public ASTOpNode buildOperatorNode(Operator op,
Node lhs,
Node rhs)
throws ParseException
NodeFactory
buildOperatorNode in class NodeFactoryParseException
public ASTOpNode buildOperatorNode(Operator op,
Node child)
throws ParseException
NodeFactory
buildOperatorNode in class NodeFactoryParseException
public ASTOpNode buildOperatorNode(Operator op,
Node[] arguments)
throws ParseException
NodeFactory
buildOperatorNode in class NodeFactoryop - the operator to usearguments - the arguments to the function.
ParseExceptionpublic ASTOpNode buildUnfinishedOperatorNode(Operator op)
NodeFactory
buildUnfinishedOperatorNode in class NodeFactory
public ASTVarNode buildVariableNode(ASTVarNode node)
throws ParseException
NodeFactory
buildVariableNode in class NodeFactoryParseException
public ASTVarNode buildVariableNode(java.lang.String name)
throws ParseException
NodeFactory
buildVariableNode in class NodeFactoryname - the name of the variable
ParseException
public ASTVarNode buildVariableNode(Variable var)
throws ParseException
NodeFactory
buildVariableNode in class NodeFactoryParseException
public ASTVarNode buildVariableNodeCheckUndeclared(java.lang.String name)
throws ParseException
NodeFactory
buildVariableNodeCheckUndeclared in class NodeFactoryname - name of the variable
ParseException - if undeclared variables are not allowed and the variable does not existpublic JepComponent getLightWeightInstance()
JepComponent
getLightWeightInstance in interface JepComponentgetLightWeightInstance in class NodeFactorypublic void init(Jep jep)
JepComponent
init in interface JepComponentinit in class NodeFactoryjep - the current Jep instancepublic NodeFactory getRoot()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||