Class NumberLexer

java.lang.Object
de.monticore.symboltable.serialization.NumberLexer

public class NumberLexer extends Object
This class is used by the JsonLexer. It realizes a DFA to check whether a char sequence is a valid json number, i.e. if it conforms to the regex: "-?(0|([1-9][0-9]*))(\\.[0-9]+)?((e|E)(-|\\+)?[0-9]+)?"
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected de.monticore.symboltable.serialization.NumberLexer.State
     
    protected StringBuilder
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    returns the string of the number read so far
    boolean
    returns true, iff the number parser is in an error state
    boolean
    returns true, iff the number parser is in a final state, i.e., if the string lexd so far is a valid number
    protected void
    readAfterE(char input)
    after an exponent character 'e', either the signum of the exponent oder a digit can follow
    protected void
    readAfterESignum(char input)
     
    protected void
    readAfterPoint(char input)
    after the decimal point, any digit can follow.
    protected void
    after the decimal point and a conscutive digit, the parser is in a final state and any digits, or the exponent character can follow.
    protected void
    readAfterSignum(char input)
     
    protected void
    readAfterZero(char input)
    after zero, any non-zero(!) digit can follow, or a decimal point or an exponent character.
    protected void
     
    protected void
    readInitial(char input)
     
    protected void
    readInNumber(char input)
    after the a minus character or a zero, any digits can follow, or a decimal point, or an exponent character
    void
    resets the current state to the initial state and resets the read input
    void
    step(char input)
    this realizes the automaton described in www.json.org

    Methods inherited from class java.lang.Object

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

    • currentState

      protected de.monticore.symboltable.serialization.NumberLexer.State currentState
    • result

      protected StringBuilder result
  • Constructor Details

    • NumberLexer

      public NumberLexer()
  • Method Details

    • reset

      public void reset()
      resets the current state to the initial state and resets the read input
    • getResult

      public String getResult()
      returns the string of the number read so far
      Returns:
    • step

      public void step(char input)
      this realizes the automaton described in www.json.org
      Parameters:
      input -
    • readInExponentAndOneDigit

      protected void readInExponentAndOneDigit(char input)
    • readAfterESignum

      protected void readAfterESignum(char input)
    • readAfterE

      protected void readAfterE(char input)
      after an exponent character 'e', either the signum of the exponent oder a digit can follow
      Parameters:
      input -
    • readAfterPointAndOneDigit

      protected void readAfterPointAndOneDigit(char input)
      after the decimal point and a conscutive digit, the parser is in a final state and any digits, or the exponent character can follow.
      Parameters:
      input -
    • readAfterPoint

      protected void readAfterPoint(char input)
      after the decimal point, any digit can follow.
      Parameters:
      input -
    • readInNumber

      protected void readInNumber(char input)
      after the a minus character or a zero, any digits can follow, or a decimal point, or an exponent character
      Parameters:
      input -
    • readAfterZero

      protected void readAfterZero(char input)
      after zero, any non-zero(!) digit can follow, or a decimal point or an exponent character.
      Parameters:
      input -
    • readAfterSignum

      protected void readAfterSignum(char input)
    • readInitial

      protected void readInitial(char input)
    • hasError

      public boolean hasError()
      returns true, iff the number parser is in an error state
      Returns:
    • isInFinalState

      public boolean isInFinalState()
      returns true, iff the number parser is in a final state, i.e., if the string lexd so far is a valid number
      Returns: