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 Details

  • 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

      Boolean isSymbol(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 ne null.
      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()