Package com.scriptbasic.interfaces
Interface LexicalElement
- All Superinterfaces:
SourceLocationBound
- All Known Implementing Classes:
AbstractLexicalElement,BasicLexicalElement
public interface LexicalElement extends SourceLocationBound
A single lexical element that was created by the LexicalAnalyer
- Author:
- Peter Verhas
-
Field Summary
Fields Modifier and Type Field Description static intTYPE_BOOLEANstatic intTYPE_DOUBLEstatic intTYPE_IDENTIFIERstatic intTYPE_LONGstatic intTYPE_STRINGstatic intTYPE_SYMBOL -
Method Summary
Modifier and Type Method Description java.lang.BooleanbooleanValue()java.lang.DoubledoubleValue()java.lang.StringgetLexeme()Get the original representation of the lexical element the way it was specified in the source code.intgetType()Get the type of the lexical element.java.lang.BooleanisBoolean()java.lang.BooleanisDouble()java.lang.BooleanisIdentifier()java.lang.BooleanisLineTerminator()java.lang.BooleanisLiteralConstant()java.lang.BooleanisLong()java.lang.BooleanisNumeric()java.lang.BooleanisStatementSeparator()java.lang.BooleanisString()java.lang.BooleanisSymbol()java.lang.BooleanisSymbol(java.lang.String lexeme)Return true if the lexical element is a symbol and the lexeme matches the the actual symbol.java.lang.LonglongValue()Get the long value of the element.java.lang.StringstringValue()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:
- Constant Field Values
-
TYPE_DOUBLE
static final int TYPE_DOUBLE- See Also:
- Constant Field Values
-
TYPE_LONG
static final int TYPE_LONG- See Also:
- Constant Field Values
-
TYPE_BOOLEAN
static final int TYPE_BOOLEAN- See Also:
- Constant Field Values
-
TYPE_IDENTIFIER
static final int TYPE_IDENTIFIER- See Also:
- Constant Field Values
-
TYPE_SYMBOL
static final int TYPE_SYMBOL- See Also:
- Constant Field Values
-
-
Method Details
-
getLexeme
java.lang.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
java.lang.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
java.lang.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:
java.lang.IllegalArgumentException- in case of exception
-
doubleValue
java.lang.Double doubleValue() -
booleanValue
java.lang.Boolean booleanValue() -
isString
java.lang.Boolean isString() -
isDouble
java.lang.Boolean isDouble() -
isLong
java.lang.Boolean isLong() -
isBoolean
java.lang.Boolean isBoolean() -
isNumeric
java.lang.Boolean isNumeric() -
isLiteralConstant
java.lang.Boolean isLiteralConstant() -
isIdentifier
java.lang.Boolean isIdentifier() -
isSymbol
java.lang.Boolean isSymbol() -
isSymbol
java.lang.Boolean isSymbol(java.lang.String lexeme)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
java.lang.Boolean isStatementSeparator()- Returns:
- true if the lexical element is colon
-
isLineTerminator
java.lang.Boolean isLineTerminator()
-