public class OPToken extends Object
OPParser
Modifier and Type | Field and Description |
---|---|
static String |
BINARY_OPERATOR_NODE
The AST node name for a Binary Operator node.
|
static String |
BINDING_NODE
The AST node name for a Binding Node.
|
static String |
CALL_NODE
The AST node name for a Method Call Node.
|
static String |
DEREF_NODE
The AST node name for a De-referencing Node.
|
static String |
FIELD_LIST
The AST node name for a Field List Node.
|
static String |
IDENTIFIER_NODE
The AST node name for an Identifier Node.
|
static String |
LIST_NODE
The AST node name for a List of Values Node.
|
static String |
LITERAL_NODE
The AST node name for a Literal Node.
|
protected int |
m_nBindingPower
The power that this token binds, typically to the left.
|
protected String |
m_sLedASTName
A functor for building ast for led method.
|
protected String |
m_sNudASTName
A functor for building ast for nud method.
|
protected String |
m_sValue
The string value of the literal.
|
static int |
PRECEDENCE_ASSIGNMENT
The binding precedence for assignment operators assignment
such as = += -= *= /= %= &= ^= |= <<= >>= >>>=
|
static int |
PRECEDENCE_BITWISE
The binding precedence for bitwise operators such as >>> >> and <<
|
static int |
PRECEDENCE_EXPONENT
The binding precedence for exponent arithmetic, i.e. raising by a power
|
static int |
PRECEDENCE_IDENTIFIER
The binding precedence for identifier tokens
|
static int |
PRECEDENCE_KEYWORD
The binding precedence for keyword tokens
|
static int |
PRECEDENCE_LOGICAL
The binding precedence for logical tokens such as &&, ||, etc
|
static int |
PRECEDENCE_LOGICAL_BITWISE
The binding precedence for bitwise logical tokens such as &, |, ^ etc
|
static int |
PRECEDENCE_PARENTHESES
The binding precedence for parentheses ( ) [ ]
|
static int |
PRECEDENCE_PRODUCT
The binding precedence for product arithmetic, multiplication, division, mod * / %
|
static int |
PRECEDENCE_RELATIONAL
The binding precedence for relational operators such as ==, <=, like, contains etc
|
static int |
PRECEDENCE_SUM
The binding precedence for sum arithmetic, i.e. + and -
|
static int |
PRECEDENCE_UNARY
The binding precedence for other unary operators: pre-increment, pre-decrement, plus, minus,
logical negation, bitwise complement, type cast ++expr --expr +expr -expr !
|
static int |
PRECEDENCE_UNARY_POST
The binding precedence for unary post operators such as post-increment and post-decrement
of the form expr++ or expr--
|
static String |
UNARY_OPERATOR_NODE
The AST node name for a Unary Operator Node.
|
Constructor and Description |
---|
OPToken()
Construct a new OPToken.
|
OPToken(String sId)
Construct a new OPToken with the given parameters.
|
OPToken(String sId,
int nBp)
Construct a new OPToken with the given parameters.
|
OPToken(String sId,
int nBp,
String sAstName)
Construct a new OPToken with the given parameters.
|
OPToken(String sId,
int nBp,
String sLedASTName,
String sNudASTName)
Construct a new OPToken with the given parameters.
|
OPToken(String sId,
String sAstName)
Construct a new OPToken with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
getBindingPower()
Get The binding precedence of this token.
|
String |
getId()
Obtain the string representation of this token.
|
String |
getLedASTName()
Get led AST Name for this token
|
String |
getNudASTName()
Get nud AST Name for this token
|
String |
getValue()
Get a string value that identifies this token
|
int |
hashCode() |
Term |
led(OPParser parser,
Term leftNode)
Process this token and possibly the given leftNodein the context of
a parser with the left denotation.
|
int |
leftBindingPower()
Obtain the power that this token will bind to the left.
|
protected Term |
newAST(String sAstName,
String sFunctor)
Create an Abstract Syntax Node for the given arguments.
|
protected Term |
newAST(String sAstName,
String sFunctor,
Term term)
Create an Abstract Syntax Node for the given arguments.
|
protected Term |
newAST(String sAstName,
String sFunctor,
Term t1,
Term t2)
Create an Abstract Syntax Node for the given arguments.
|
protected Term |
newAST(String sAstName,
String sFunctor,
Term t1,
Term t2,
Term t3)
Create an Abstract Syntax Node for the given arguments.
|
protected Term |
newAST(String sAstName,
Term term)
Create an Abstract Syntax Node for the given arguments.
|
Term |
nud(OPParser parser)
Process this token in the context of parser p with the null
denotation.
|
void |
setBindingPower(int nBp)
Set The binding precedence that this token will use for binding to the right.
|
void |
setId(String sId)
Set the string representation of this token to the given id.
|
void |
setLedASTName(String sAstName)
Set the led AST Name for this token to be the given string
|
void |
setNudASTName(String sAstName)
Set the nud AST Name for this token to be the given string
|
void |
setValue(String s)
Set the AST Name for this token to be the given string
|
String |
toString()
Return a human-readable description for this token.
|
public static String BINARY_OPERATOR_NODE
public static String BINDING_NODE
public static String CALL_NODE
public static String DEREF_NODE
public static String FIELD_LIST
public static String IDENTIFIER_NODE
public static String LIST_NODE
public static String LITERAL_NODE
public static String UNARY_OPERATOR_NODE
public static final int PRECEDENCE_KEYWORD
public static final int PRECEDENCE_IDENTIFIER
public static final int PRECEDENCE_ASSIGNMENT
public static final int PRECEDENCE_LOGICAL
public static final int PRECEDENCE_LOGICAL_BITWISE
public static final int PRECEDENCE_RELATIONAL
public static final int PRECEDENCE_BITWISE
public static final int PRECEDENCE_SUM
public static final int PRECEDENCE_PRODUCT
public static final int PRECEDENCE_EXPONENT
public static final int PRECEDENCE_UNARY
public static final int PRECEDENCE_UNARY_POST
public static final int PRECEDENCE_PARENTHESES
protected String m_sValue
protected String m_sLedASTName
protected String m_sNudASTName
protected int m_nBindingPower
public OPToken()
public OPToken(String sId)
sId
- string representation of the literalpublic OPToken(String sId, int nBp)
sId
- string representation of the tokennBp
- The binding precedence for this tokenpublic OPToken(String sId, String sAstName)
sId
- string representation of the tokensAstName
- the type code for this literal tokenpublic OPToken(String sId, int nBp, String sAstName)
sId
- string representation of the tokennBp
- The binding precedence for this tokensAstName
- the name for this tokens ASTpublic OPToken(String sId, int nBp, String sLedASTName, String sNudASTName)
sId
- string representation of the tokennBp
- The binding precedence for this tokensLedASTName
- the name for this tokens ASTsNudASTName
- the name for this tokens ASTpublic int leftBindingPower()
public Term nud(OPParser parser)
parser
- the parser that is the context for parsingpublic Term led(OPParser parser, Term leftNode)
parser
- the parser that is the context for parsingleftNode
- an ast Term that the token is possibly interested inprotected Term newAST(String sAstName, String sFunctor)
sAstName
- classification functor or nullsFunctor
- functor for ast node to be constructedprotected Term newAST(String sAstName, Term term)
sAstName
- classification functor or nullterm
- an Term that is part of the astprotected Term newAST(String sAstName, String sFunctor, Term term)
sAstName
- classification functor or nullsFunctor
- functor for ast node to be constructedterm
- an Term that is part of the astprotected Term newAST(String sAstName, String sFunctor, Term t1, Term t2)
sAstName
- classification functor or nullsFunctor
- functor for ast node to be constructedt1
- an Term that is part of the astt2
- an Term that is part of the astprotected Term newAST(String sAstName, String sFunctor, Term t1, Term t2, Term t3)
sAstName
- classification functor or nullsFunctor
- functor for ast node to be constructedt1
- an Term that is part of the astt2
- an Term that is part of the astt3
- an Term that is part of the astpublic String getId()
public void setId(String sId)
sId
- the string representation for the tokenpublic int getBindingPower()
public void setBindingPower(int nBp)
nBp
- the power power for this tokenpublic String getNudASTName()
public void setNudASTName(String sAstName)
sAstName
- the nud ast name for this tokenpublic String getLedASTName()
public void setLedASTName(String sAstName)
sAstName
- the led ast name for this tokenpublic String getValue()
public void setValue(String s)
s
- the ast name for this tokenpublic String toString()