Package com.scriptbasic.lexer
Class BasicLexicalElement
java.lang.Object
com.scriptbasic.lexer.AbstractLexicalElement
com.scriptbasic.lexer.BasicLexicalElement
- All Implemented Interfaces:
LexicalElement,SourceLocationBound
-
Field Summary
Fields inherited from interface com.scriptbasic.interfaces.LexicalElement
TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_IDENTIFIER, TYPE_LONG, TYPE_STRING, TYPE_SYMBOL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the name of the file to which the object is bound to.Get the original representation of the lexical element the way it was specified in the source code.intGet the line number to which the object is bound to.intGet the position on the line to which the object is bound to.intgetType()Get the type of the lexical element.isDouble()isLong()isString()isSymbol()Return true if the lexical element is a symbol and the lexeme matches the the actual symbol.Get the long value of the element.voidsetBooleanValue(Boolean booleanValue) voidsetDoubleValue(Double doubleValue) voidsetFileName(String fileName) voidvoidsetLineNumber(int lineNumber) voidsetLongValue(long longValue) voidsetPosition(int position) voidsetStringValue(String stringValue) voidsetType(int type) Get the string value of the lexical element.toString()Methods inherited from class com.scriptbasic.lexer.AbstractLexicalElement
isLiteralConstant, isNumeric
-
Constructor Details
-
BasicLexicalElement
public BasicLexicalElement()
-
-
Method Details
-
getPosition
public int getPosition()Description copied from interface:SourceLocationBoundGet the position on the line to which the object is bound to.- Returns:
- the position within the line
-
setPosition
public void setPosition(int position) -
getLexeme
Description copied from interface:LexicalElementGet the original representation of the lexical element the way it was specified in the source code.- Returns:
- the lexical element as string
-
setLexeme
-
getFileName
Description copied from interface:SourceLocationBoundGet the name of the file to which the object is bound to.- Returns:
- the name of the file
-
setFileName
-
getLineNumber
public int getLineNumber()Description copied from interface:SourceLocationBoundGet the line number to which the object is bound to.- Returns:
- the line number in the file
-
setLineNumber
public void setLineNumber(int lineNumber) -
getType
public int getType()Description copied from interface:LexicalElementGet the type of the lexical element.- Returns:
- return value
-
setType
public void setType(int type) -
setStringValue
-
setLongValue
public void setLongValue(long longValue) -
setDoubleValue
-
setBooleanValue
-
stringValue
Description copied from interface:LexicalElementGet the string value of the lexical element. This method should be called only when the lexical element is a string literal. Otherwise the implementation will throw IllegalArgumentException();- Returns:
- return value
-
longValue
Description copied from interface:LexicalElementGet the long value of the element. This method should only be called when the type of the symbol is long. Otherwise the implementation will throw IllegalArgumentException();- Returns:
- return value
-
doubleValue
-
booleanValue
-
isBoolean
-
isString
-
isDouble
-
isLong
-
isIdentifier
-
isSymbol
-
isSymbol
Description copied from interface:LexicalElementReturn true if the lexical element is a symbol and the lexeme matches the the actual symbol.- Parameters:
lexeme- to match by the lexical element. The parameter must not nenull.- Returns:
- true if the lexical element is a symbol and the lexeme matches
the parameter
lexeme.
-
toString
-
isLineTerminator
-
isStatementSeparator
- Returns:
- true if the lexical element is colon
-