Class ExprParserR7

java.lang.Object
com.aquima.interactions.expressions.r7.ExprParserR7
All Implemented Interfaces:
IExprParser

public final class ExprParserR7 extends Object implements IExprParser
Implementation of the IExpressionParser interface for the 4.2 expression syntax.
Since:
5.0
Author:
O. Kerpershoek, F. van der Meer
  • Constructor Details

    • ExprParserR7

      public ExprParserR7(IExprDS expressionDS, IDefinitionSource definitions, boolean semanticR7Mode)
      Constructs an expression parser using the custom functions provided by the data source.
      Parameters:
      expressionDS - The data source containing the information needed to construct the expression parser.
      definitions - Object containing the definitions that may be used in expressions.
      semanticR7Mode - A boolean indicating if the semantic operation mode of version 7.0 will be activated.
    • ExprParserR7

      public ExprParserR7(IExprDS expressionDS, IDefinitionSource definitions)
      Constructs an expression parser using the custom functions provided by the data source.
      Parameters:
      expressionDS - The data source containing expression configuration options.
      definitions - Object containing the definitions that may be used in expressions.
  • Method Details

    • analyze

      public ISemanticNode analyze(String id, String expression, IParseListener listener)
      Description copied from interface: IExprParser
      This method parses the expression into a semantic tree.
      Specified by:
      analyze in interface IExprParser
      Parameters:
      id - Optional unique ID to identify the expression being parsed.
      expression - The string containing the expression that should be parsed.
      listener - a listener that will be notified on error or warning messages.
      Returns:
      Semantic tree for the expression.
    • analyze

      public ISemanticNode analyze(String id, String expression, Type resultType, IParseListener listener)
      Description copied from interface: IExprParser
      This method parses the expression into a semantic tree.
      Specified by:
      analyze in interface IExprParser
      Parameters:
      id - Optional unique ID to identify the expression being parsed.
      expression - The string containing the expression that should be parsed.
      resultType - The type the expression should result in.
      listener - a listener that will be notified on error or warning messages.
      Returns:
      Semantic tree for the expression.
    • parse

      public IExpr parse(String id, String expression, IParseListener listener)
      Description copied from interface: IExprParser
      This method parses the expression using the definitions provided into an expression object.
      Specified by:
      parse in interface IExprParser
      Parameters:
      id - Optional unique ID to identify the expression being parsed.
      expression - The string containing the expression that should be parsed.
      listener - a listener that will be notified on error or warning messages.
      Returns:
      Expression object for the expression string passed.
    • parse

      public IExpr parse(String id, String expression, Type resultType, IParseListener listener)
      Description copied from interface: IExprParser
      This method parses the expression using the definitions provided into an expression object. The resulting expression will return a value of the provided type, or fail parsing when the expression result could not be converted to the requested type.
      Specified by:
      parse in interface IExprParser
      Parameters:
      id - Optional unique ID to identify the expression being parsed.
      expression - The string containing the expression that should be parsed.
      resultType - The type the expression should result in.
      listener - a listener that will be notified on error or warning messages.
      Returns:
      Expression object for the expression string passed.
    • parseSuggestions

      public static void parseSuggestions(String unitName, String expression, ISuggestionListener listener)
      This method parses the syntax of the expression and notifies the listener of possible other symbols. The method is intended for use for syntax highlighting and auto completion. *
      Parameters:
      unitName - the name of the unit
      expression - the expression
      listener - the listener
      Throws:
      ParseException - when something goes wrong
    • parseSyntax

      public static IParseNode parseSyntax(String unitName, String expression, MessageReporter reporter)
      This method parses the syntax into an expression node. If the parse fails a ParseFailureException is thrown.
      Parameters:
      unitName - The name of the unit that is to be parsed.
      expression - The expression to parse.
      reporter - The message reporter to which the errors can be reported.
      Returns:
      An ExpressionNode object which is never null
      Throws:
      ParseException - This exception is thrown when the expression could not be parsed due to (syntax) errors.
    • parseTsl

      public TslText parseTsl(String id, String text, IParseListener listener)
      Description copied from interface: IExprParser
      This method parses the TSL string provided into a TSL text object. If an error of a tsl text occurs this parse function will fail.
      Specified by:
      parseTsl in interface IExprParser
      Parameters:
      id - Optional unique ID to identify the text being parsed.
      text - The text that should be parsed.
      listener - Listener that should be notified of errors and warnings.
      Returns:
      TslText object containing the parsed text.
    • spawnLocalParser

      public ILocalParser spawnLocalParser()
      Description copied from interface: IExprParser
      Creates a localised expression parser which has a new scope in which one can define new variables etc.
      Specified by:
      spawnLocalParser in interface IExprParser
      Returns:
      A localised parser which should never be null.