Class ExprParser


  • public class ExprParser
    extends Object
    Class containing methods to create parser for parsing Boolean expressions.
    Author:
    Herbert Praehofer
    • Field Detail

      • litParser

        public final Parser<Expr.Lit> litParser
        Parser for Boolean literals.
      • notParser

        public final Parser<Expr.Not> notParser
        Parser for not-expressions.
      • orParser

        public final Parser<Expr.Or> orParser
        Parser for or-expressions.
      • andParser

        public final Parser<Expr.And> andParser
        Parser for and-expressions.
      • exprParserDefected

        public final Parser<Expr> exprParserDefected
        Defected implementation of expression parser. Using parser in an alternative results in endless loops.
      • exprParser

        public Parser<Expr> exprParser
        Variable to memoize the created expression parser.
    • Constructor Detail

      • ExprParser

        public ExprParser()
    • Method Detail

      • exprParser

        public Parser<Expr> exprParser()
        Creates an parser for Boolean expressions. It uses the method for creating a parser from a list of supplier functions for the alternatives. Memoizes the parser once created.
        Returns:
        the parser for Boolean expressions.
      • parse

        public Result<Expr> parse​(FList<String> tokens)
        Applies the expression parser on a list of tokens.
        Parameters:
        tokens - the list of tokens
        Returns:
        the parse result
      • parse

        public Result<Expr> parse​(String input)
        Applies the expression parser on an input string. From the input string a list of tokens is created.
        Parameters:
        input - the input string
        Returns:
        the parse result