Package edu.odu.cs.cs350
Class Token
- java.lang.Object
-
- edu.odu.cs.cs350.Token
-
- All Implemented Interfaces:
TokenInterface
public class Token extends java.lang.Object implements TokenInterface
Token file contains the information needed for a token defined in the TokenType class. Token metadata includes tokentype, string lexeme of Identifier or Number, the line number of the token, and the column number of the token.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAbsolutePath()java.lang.StringgetColumnNumber()java.lang.StringgetLexeme()java.lang.StringgetLineNumber()TokenTypegetTokenType()java.lang.StringprintToken()voidsetAbsolutePath(java.lang.String absolutePath)java.lang.StringtoString()Representation of the token in two format according to the use of constructor.
-
-
-
Constructor Detail
-
Token
public Token(TokenType type, int line, int column)
- Parameters:
type- Type of token given in the TokenType classline- line number of the current tokencolumn- line number of the current token
-
Token
public Token(TokenType type, int line, int column, java.lang.String lexeme)
- Parameters:
type- Type of token given in the TokenType classline- line number of the current tokencolumn- starting column number of the current tokenlexeme- string representation of this token
-
-
Method Detail
-
getTokenType
public TokenType getTokenType()
- Specified by:
getTokenTypein interfaceTokenInterface- Returns:
- the token type of this current token.
-
getLexeme
public java.lang.String getLexeme()
- Specified by:
getLexemein interfaceTokenInterface- Returns:
- the string lexeme of this current token, empty if it's not an Identifier or a number.
-
getLineNumber
public java.lang.String getLineNumber()
- Specified by:
getLineNumberin interfaceTokenInterface- Returns:
- the line number of this current token in string format.
-
getColumnNumber
public java.lang.String getColumnNumber()
- Specified by:
getColumnNumberin interfaceTokenInterface- Returns:
- the column number of this current token in string format for string literals, the column number will be the ending of the string. (i.e. the second quotation)
-
toString
public java.lang.String toString()
Representation of the token in two format according to the use of constructor.- Specified by:
toStringin interfaceTokenInterface- Overrides:
toStringin classjava.lang.Object
-
getAbsolutePath
public java.lang.String getAbsolutePath()
- Specified by:
getAbsolutePathin interfaceTokenInterface
-
setAbsolutePath
public void setAbsolutePath(java.lang.String absolutePath)
-
printToken
public java.lang.String printToken()
- Specified by:
printTokenin interfaceTokenInterface
-
-