Class Decimal

java.lang.Object
com.scriptbasic.lexer.elements.AbstractElementAnalyzer
com.scriptbasic.lexer.elements.Decimal
All Implemented Interfaces:
LexicalElementAnalyzer

public class Decimal
extends AbstractElementAnalyzer
  • Constructor Summary

    Constructors 
    Constructor Description
    Decimal​(SourceReader reader)  
  • Method Summary

    Modifier and Type Method Description
    LexicalElement read()
    Read a decimal number from the input.

    Methods inherited from class com.scriptbasic.lexer.elements.AbstractElementAnalyzer

    getReader

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • read

      public LexicalElement read()
      Read a decimal number from the input. The next character following the number is left in the input stream to be available for the next getReader().get().

      A decimal number does NOT have + or - sign, because that would cause trouble parsing expressions. It contains digits, optionally decimal point and exponent part following 'e' or 'E'.

      Some languages allow formats like 1. or .12. This parser does not allow such unreadable format. If there is a decimal point then there has to be a digit on each side.

      The returned lexeme will be double if there is decimal point or exponent part or both, even if the resulting value could be presented as long. Thus 1.12E2 is a double number and not a long containing 112.

      Specified by:
      read in interface LexicalElementAnalyzer
      Specified by:
      read in class AbstractElementAnalyzer
      Returns:
      the lexical element containing the long or double value