Class JsonLexer

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

public class JsonLexer extends Object
This class is responsible to tokenize a String that encoded as JSON. The length of the input, thus, is limited by the maximum length of a String.
  • Field Details

  • Constructor Details

    • JsonLexer

      public JsonLexer(String input)
      The lexer tokenizes the passed input String.
      Parameters:
      input -
  • Method Details

    • hasNext

      public boolean hasNext()
      returns truee, iff the end of the String lexed so far is not reached.
      Returns:
    • getRemainder

      public String getRemainder()
      Returns the part of the input that has not been lexed yet (e.g., for prin
      Returns:
    • peek

      public JsonToken peek()
      reads the next token of the input, without consuming it. In Json, each kind of token can be identified by its first character.
      Returns:
    • la

      protected char la(int i)
      Returns the character at the i-th position from the current position of the input.
      Parameters:
      i -
      Returns:
    • poll

      public JsonToken poll()
      returns the next token and removes it
      Returns:
    • checkNumber

      protected JsonToken checkNumber()
      try to read a number starting at the current location
      Returns:
    • checkString

      protected JsonToken checkString()
      checks, if the current input is a valid JSON String, i.e. if it is conform to the regex: String regex = "" + "\"" //start with '"' + "(" //begin iteration of characters + "[^\\\"\\\\]" //every character except '"' or "\" + "|\\\\u[0-9A-Fa-f]{4}" //or unicode escape sequence + "|\\\\[bfnrt\"/\\\\]" // or other escape sequence + ")*" //end iteration of characters + "\""; //end with '"'
      Returns: