Class DictionaryGrammarMatcher

java.lang.Object
com.singularsys.jep.misc.dictionary.DictionaryGrammarMatcher
All Implemented Interfaces:
GrammarMatcher, Serializable

public class DictionaryGrammarMatcher extends Object implements GrammarMatcher
A GrammarMatcher for JSON like map syntax.
map = {'x':2, 'y':3}
On parsing this produces an ASTOpNode with the MapPfmc, each child is another ASTOpNode with the MapPfmc.MapEntryPfmc and two children, the key and value.
Since:
Jep 4.1
See Also:
  • Field Details

  • Constructor Details

    • DictionaryGrammarMatcher

      public DictionaryGrammarMatcher(DictionaryGrammarMatcher.Type type, Token open, Token close, Token colon, Token comma, Operator dict, Operator entry)
      Create a DictionaryGrammarMatcher
      Parameters:
      open - token representing an opening bracket
      close - token representing a closing bracket
      colon - token representing the key value separator
      comma - token representing a list item separator
      dict - the operator used for creating maps
      entry - the operator used for creating map entries
  • Method Details

    • init

      public void init(Jep jep)
      Description copied from interface: GrammarMatcher
      Delayed initialisation, this method is called whenever components of the jep instance are changed.
      Specified by:
      init in interface GrammarMatcher
      Parameters:
      jep - the current jep instance.
    • match

      public Node match(Lookahead2Iterator<Token> it, GrammarParser parser) throws ParseException
      Attempt to match a function, calls the GrammarParser.parseSubExpression() to match function arguments.
      Specified by:
      match in interface GrammarMatcher
      Parameters:
      it - An iterator inspecting the input
      parser - the parser to use when evaluating sub expressions
      Returns:
      if matched returns a node representing the content, return null is does not match
      Throws:
      ParseException - if there is a syntactical error in the input.