Interface CommonParser


public interface CommonParser
Specifies the methods which are implemented by the common parser to be called-back by the custom parser. (( ?? FIXME Additionally the min parser function itself)) ????
  • Field Details

    • SWITCH_DEFAULT_TOKENTYPE

      static final TokenType SWITCH_DEFAULT_TOKENTYPE
      The token type which leads-in the default case in a switch statement.
    • SWITCH_DEFAULT_TERMINAL

      static final String SWITCH_DEFAULT_TERMINAL
      The terminal symbol which leads-in the default case in a switch statement.
      See Also:
  • Method Details

    • newInstance

      static CommonParser newInstance(MessageReceiver<SimpleMessage<String>> msg, Collection<TokenRule<TokenType>> customTokenRules)
      Yields a new instance of an implementation.

      (This allows technically that the implementing class is not known by a client classes = a custom compiler.)

      Parameters:
      msg - the target of all generated errors and warnings.
      customTokenRules - additional token rules from the custom layer.
      Returns:
      an instance of an implementation of this interface.
    • parse

      @Opt Model.Expr parse(String source, String sourceIndication)
      Parse the given source test.
      Parameters:
      source - to be parsed
      sourceIndication - to be used in the document id of all messages.
      Returns:
      the model element which represents the parsed result, or null in case of errors.
    • error

      void error(@Opt Location<String> loc, String text, Object... args)
      Service for the custom layer to send messages to the same target as the common layer.
      Parameters:
      loc - the source text location of the error
      text - the message text.
      args - the arguments to evaluate the text by String.format(java.lang.String, java.lang.Object...).
    • la

      boolean la(TokenType tokenType)
      Return whether the next token as the given type.
      Parameters:
      tokenType - to test for
      Returns:
      whether the next token as the given type.
    • accept

      void accept()
      Consume the current token and fetch the next one to be the current token.
    • number

      @Opt Integer number()
      Accepts an integer number text representation and returns it conversion result. If no such token is current, return null. Sends an error if the numeric value cannot be conerted to an "int" primitive type.
      Returns:
      the parsed number, or null if the current input does not stand for a valid number.
    • setCustomParser

      void setCustomParser(CustomParser customParser)
      Set the custom-level parser, so that it can be called by the common parser, whenever the syntax requires it.
      Parameters:
      customParser - the custom-level parser to be called by the common parser, whenever the syntax requires it.
    • location

      Location<String> location()
      Return the location informatio of the current token.
      Returns:
      the location informatio of the current token.
    • getTokenText

      String getTokenText()
      Return the text content of the current token.
      Returns:
      the text content of the current token.
    • getTokenType

      TokenType getTokenType()
      Return the type of the current token.
      Returns:
      the type of the current token.