Package com.scriptbasic.lexer
Class BasicLexicalElement
java.lang.Object
com.scriptbasic.lexer.AbstractLexicalElement
com.scriptbasic.lexer.BasicLexicalElement
- All Implemented Interfaces:
LexicalElement,SourceLocationBound
public class BasicLexicalElement extends AbstractLexicalElement
-
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 Constructor Description BasicLexicalElement() -
Method Summary
Modifier and Type Method Description java.lang.BooleanbooleanValue()java.lang.DoubledoubleValue()java.lang.StringgetFileName()Get the name of the file to which the object is bound to.java.lang.StringgetLexeme()Get the original representation of the lexical element the way it was specified in the source code.intgetLineNumber()Get the line number to which the object is bound to.intgetPosition()Get the position on the line to which the object is bound to.intgetType()Get the type of the lexical element.java.lang.BooleanisBoolean()java.lang.BooleanisDouble()java.lang.BooleanisIdentifier()java.lang.BooleanisLineTerminator()java.lang.BooleanisLong()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.voidsetBooleanValue(java.lang.Boolean booleanValue)voidsetDoubleValue(java.lang.Double doubleValue)voidsetFileName(java.lang.String fileName)voidsetLexeme(java.lang.String lexeme)voidsetLineNumber(int lineNumber)voidsetLongValue(long longValue)voidsetPosition(int position)voidsetStringValue(java.lang.String stringValue)voidsetType(int type)java.lang.StringstringValue()Get the string value of the lexical element.java.lang.StringtoString()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
public java.lang.String 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
public void setLexeme(java.lang.String lexeme) -
getFileName
public java.lang.String 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
public void setFileName(java.lang.String fileName) -
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
public void setStringValue(java.lang.String stringValue) -
setLongValue
public void setLongValue(long longValue) -
setDoubleValue
public void setDoubleValue(java.lang.Double doubleValue) -
setBooleanValue
public void setBooleanValue(java.lang.Boolean booleanValue) -
stringValue
public java.lang.String 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
public java.lang.Long 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
public java.lang.Double doubleValue() -
booleanValue
public java.lang.Boolean booleanValue() -
isBoolean
public java.lang.Boolean isBoolean() -
isString
public java.lang.Boolean isString() -
isDouble
public java.lang.Boolean isDouble() -
isLong
public java.lang.Boolean isLong() -
isIdentifier
public java.lang.Boolean isIdentifier() -
isSymbol
public java.lang.Boolean isSymbol() -
isSymbol
public java.lang.Boolean isSymbol(java.lang.String lexeme)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
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
isLineTerminator
public java.lang.Boolean isLineTerminator() -
isStatementSeparator
public java.lang.Boolean isStatementSeparator()- Returns:
- true if the lexical element is colon
-