java.lang.Object
com.maroontress.clione.impl.DefaultToken
- All Implemented Interfaces:
Token
The implementation of a preprocessing token.
-
Constructor Summary
ConstructorDescriptionDefaultToken
(Collection<SourceChar> chars, TokenType type) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptiongetChars()
Returns the characters that compose this token.Returns the child tokens.getSpan()
Returns a new span representing the range of this token in the source file.getType()
Returns the type of this token.getValue()
Returns a new string representing this token.toString()
Returns a new string representation of this token that is easy for a person to read.withChildren
(Collection<Token> newChildren) Returns a new token that has the same content of this token but has the specified child tokens.Returns a new token that has the same content of this token but has the specified token type.
-
Constructor Details
-
DefaultToken
Creates a new instance.- Parameters:
chars
- The collection ofSourceChar
objects that compose this token. It must not contain any character representing EOF.type
- The token type of this token.
-
-
Method Details
-
getValue
Returns a new string representing this token.The string that this method returns does not have the clue of the token type and does not include the content of the child tokens.
-
getSpan
Returns a new span representing the range of this token in the source file. -
getChars
Returns the characters that compose this token. -
getType
Returns the type of this token. -
getChildren
Returns the child tokens.This method returns an empty list if this token has no child tokens.
- Specified by:
getChildren
in interfaceToken
- Returns:
- The unmodifiable list containing the child tokens.
-
withType
Returns a new token that has the same content of this token but has the specified token type. -
withChildren
Returns a new token that has the same content of this token but has the specified child tokens.- Specified by:
withChildren
in interfaceToken
- Parameters:
newChildren
- The child tokens of the new token.- Returns:
- The new token.
-
toString
Returns a new string representation of this token that is easy for a person to read.This method returns a string equal to the value of:
"[value=" + getValue() + ", span=" + getSpan() + ", " + "chars=" + getChars() + ", type=" + getType() + ", " + "children=" + getChildren() + "]";
-