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

  • 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 java.lang.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​(java.lang.String lexeme)
    • getFileName

      public java.lang.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​(java.lang.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​(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: 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 java.lang.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 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: 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 java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • isLineTerminator

      public java.lang.Boolean isLineTerminator()
    • isStatementSeparator

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