Class BasicLexicalElement

java.lang.Object
com.scriptbasic.lexer.AbstractLexicalElement
com.scriptbasic.lexer.BasicLexicalElement
All Implemented Interfaces:
LexicalElement, SourceLocationBound

public class BasicLexicalElement extends AbstractLexicalElement
  • Constructor Details

    • BasicLexicalElement

      public BasicLexicalElement()
  • Method Details

    • getPosition

      public int getPosition()
      Description copied from interface: SourceLocationBound
      Get 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 String getLexeme()
      Description copied from interface: LexicalElement
      Get 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(String lexeme)
    • getFileName

      public String getFileName()
      Description copied from interface: SourceLocationBound
      Get the name of the file to which the object is bound to.
      Returns:
      the name of the file
    • setFileName

      public void setFileName(String fileName)
    • getLineNumber

      public int getLineNumber()
      Description copied from interface: SourceLocationBound
      Get 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: LexicalElement
      Get the type of the lexical element.
      Returns:
      return value
    • setType

      public void setType(int type)
    • setStringValue

      public void setStringValue(String stringValue)
    • setLongValue

      public void setLongValue(long longValue)
    • setDoubleValue

      public void setDoubleValue(Double doubleValue)
    • setBooleanValue

      public void setBooleanValue(Boolean booleanValue)
    • stringValue

      public String stringValue()
      Description copied from interface: LexicalElement
      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

      public Long longValue()
      Description copied from interface: LexicalElement
      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
    • doubleValue

      public Double doubleValue()
    • booleanValue

      public Boolean booleanValue()
    • isBoolean

      public Boolean isBoolean()
    • isString

      public Boolean isString()
    • isDouble

      public Boolean isDouble()
    • isLong

      public Boolean isLong()
    • isIdentifier

      public Boolean isIdentifier()
    • isSymbol

      public Boolean isSymbol()
    • isSymbol

      public Boolean isSymbol(String lexeme)
      Description copied from interface: LexicalElement
      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 ne null.
      Returns:
      true if the lexical element is a symbol and the lexeme matches the parameter lexeme.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isLineTerminator

      public Boolean isLineTerminator()
    • isStatementSeparator

      public Boolean isStatementSeparator()
      Returns:
      true if the lexical element is colon