Package net.aifusion.asn
Class Token
java.lang.Object
net.aifusion.asn.Token
Class to represent a lexical token
- Author:
- Sharad Singhal
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if this token is of a given typeboolean
void
setPosition
(int lineNumber, int cursor) Set the input position for this tokenvoid
Reset the type of this token to the expected typetoString()
type()
Get the type of this tokenvalue()
Get the value of this token
-
Constructor Details
-
Token
Create a token for a given type- Parameters:
type
- - type of token
-
Token
Create a token with given type and value- Parameters:
type
- - token typevalue
- - value of the token
-
-
Method Details
-
is
Check if this token is of a given type- Parameters:
expected
- - expected type of the token- Returns:
- - true if the token type matches the expected type, false otherwise
-
isBuiltInType
public boolean isBuiltInType() -
setType
Reset the type of this token to the expected type- Parameters:
expected
- - expected type of the token
-
setPosition
public void setPosition(int lineNumber, int cursor) Set the input position for this token- Parameters:
lineNumber
- - line number in inputcursor
- - cursor within the line
-
value
Get the value of this token- Returns:
- - value of the token. '??' returned if the token does not have a value
-
type
Get the type of this token- Returns:
- - type of the token
-
toString
-