Class NumberLexer
java.lang.Object
de.monticore.symboltable.serialization.NumberLexer
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
FieldsModifier and TypeFieldDescriptionprotected de.monticore.symboltable.serialization.NumberLexer.Stateprotected StringBuilder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreturns the string of the number read so farbooleanhasError()returns true, iff the number parser is in an error statebooleanreturns true, iff the number parser is in a final state, i.e., if the string lexd so far is a valid numberprotected voidreadAfterE(char input) after an exponent character 'e', either the signum of the exponent oder a digit can followprotected voidreadAfterESignum(char input) protected voidreadAfterPoint(char input) after the decimal point, any digit can follow.protected voidreadAfterPointAndOneDigit(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.protected voidreadAfterSignum(char input) protected voidreadAfterZero(char input) after zero, any non-zero(!) digit can follow, or a decimal point or an exponent character.protected voidreadInExponentAndOneDigit(char input) protected voidreadInitial(char input) protected voidreadInNumber(char input) after the a minus character or a zero, any digits can follow, or a decimal point, or an exponent charactervoidreset()resets the current state to the initial state and resets the read inputvoidstep(char input) this realizes the automaton described in www.json.org
-
Field Details
-
currentState
protected de.monticore.symboltable.serialization.NumberLexer.State currentState -
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
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:
-