Package org.ek9lang.compiler.tokenizer
Class Ek9Token
java.lang.Object
org.ek9lang.compiler.tokenizer.Ek9Token
- All Implemented Interfaces:
Serializable
,IToken
Models a token that we need to create as a synthetic token.
The EK9 compiler sometimes needs to deal with tokens that were not
in the actual source code input.
- See Also:
-
Constructor Summary
ConstructorDescriptionEk9Token()
Create a new token with default name of 'Synthetic'.Ek9Token
(int type, String textName, int lineNumber, String sourceName, int charPositionInLine, int tokenIndex) Create a new token with all necessary details.Create a new token with a specific name.Create a new token with name and specific line number.Create a new token with name, specific line number and named source file.Ek9Token
(org.antlr.v4.runtime.Token token) Pull out all relevant details of an ANTLR Token into a minimal EK9Token. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
The index of the first character of this token relative to the beginning of the line at which it occurs, 0..n-1int
getLine()
The line number on which the 1st character of this token was matched, line=1..nThe name of the source (if known).getText()
The actual text of the token itself.int
An index from 0..n-1 of the token object in the input stream.int
getType()
The type of token.int
hashCode()
toString()
-
Constructor Details
-
Ek9Token
public Ek9Token()Create a new token with default name of 'Synthetic'. -
Ek9Token
Create a new token with a specific name. -
Ek9Token
Create a new token with name and specific line number. -
Ek9Token
Create a new token with name, specific line number and named source file. -
Ek9Token
public Ek9Token(int type, String textName, int lineNumber, String sourceName, int charPositionInLine, int tokenIndex) Create a new token with all necessary details. -
Ek9Token
public Ek9Token(org.antlr.v4.runtime.Token token) Pull out all relevant details of an ANTLR Token into a minimal EK9Token.
-
-
Method Details
-
getType
public int getType()Description copied from interface:IToken
The type of token. -
getText
Description copied from interface:IToken
The actual text of the token itself. -
getSourceName
Description copied from interface:IToken
The name of the source (if known).- Specified by:
getSourceName
in interfaceIToken
-
getLine
public int getLine()Description copied from interface:IToken
The line number on which the 1st character of this token was matched, line=1..n -
getCharPositionInLine
public int getCharPositionInLine()Description copied from interface:IToken
The index of the first character of this token relative to the beginning of the line at which it occurs, 0..n-1- Specified by:
getCharPositionInLine
in interfaceIToken
-
getTokenIndex
public int getTokenIndex()Description copied from interface:IToken
An index from 0..n-1 of the token object in the input stream. This must be valid in order to print token streams and use TokenRewriteStream.
Return -1 to indicate that this token was conjured up since it doesn't have a valid index.- Specified by:
getTokenIndex
in interfaceIToken
-
equals
-
hashCode
public int hashCode() -
toString
-