Package com.scriptbasic.interfaces
Interface LexicalElement
- All Superinterfaces:
SourceLocationBound
- All Known Implementing Classes:
AbstractLexicalElement,BasicLexicalElement
A single lexical element that was created by the LexicalAnalyer
- Author:
- Peter Verhas
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionGet the original representation of the lexical element the way it was specified in the source code.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.Get the string value of the lexical element.Methods inherited from interface com.scriptbasic.interfaces.SourceLocationBound
getFileName, getLineNumber, getPosition
-
Field Details
-
TYPE_STRING
static final int TYPE_STRING- See Also:
-
TYPE_DOUBLE
static final int TYPE_DOUBLE- See Also:
-
TYPE_LONG
static final int TYPE_LONG- See Also:
-
TYPE_BOOLEAN
static final int TYPE_BOOLEAN- See Also:
-
TYPE_IDENTIFIER
static final int TYPE_IDENTIFIER- See Also:
-
TYPE_SYMBOL
static final int TYPE_SYMBOL- See Also:
-
-
Method Details
-
getLexeme
String getLexeme()Get the original representation of the lexical element the way it was specified in the source code.- Returns:
- the lexical element as string
-
getType
int getType()Get the type of the lexical element.- Returns:
- return value
-
stringValue
String stringValue()Get 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
Long longValue()Get 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
- Throws:
IllegalArgumentException- in case of exception
-
doubleValue
Double doubleValue() -
booleanValue
Boolean booleanValue() -
isString
Boolean isString() -
isDouble
Boolean isDouble() -
isLong
Boolean isLong() -
isBoolean
Boolean isBoolean() -
isNumeric
Boolean isNumeric() -
isLiteralConstant
Boolean isLiteralConstant() -
isIdentifier
Boolean isIdentifier() -
isSymbol
Boolean isSymbol() -
isSymbol
Return 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.
-
isStatementSeparator
Boolean isStatementSeparator()- Returns:
- true if the lexical element is colon
-
isLineTerminator
Boolean isLineTerminator()
-