Package at.jku.ssw.fp.sect05_3.parser
Class ExprParser
- java.lang.Object
-
- at.jku.ssw.fp.sect05_3.parser.ExprParser
-
public class ExprParser extends Object
Class containing methods to create parser for parsing Boolean expressions.- Author:
- Herbert Praehofer
-
-
Field Summary
Fields Modifier and Type Field Description Parser<Expr.And>
andParser
Parser for and-expressions.Parser<Expr>
exprParser
Variable to memoize the created expression parser.Parser<Expr>
exprParserDefected
Defected implementation of expression parser.Parser<Expr.Lit>
litParser
Parser for Boolean literals.Parser<Expr.Not>
notParser
Parser for not-expressions.Parser<Expr.Or>
orParser
Parser for or-expressions.(package private) Parser<Expr.Var>
varParser
Parser for variables.
-
Constructor Summary
Constructors Constructor Description ExprParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Parser<Expr>
exprParser()
Creates an parser for Boolean expressions.Result<Expr>
parse(FList<String> tokens)
Applies the expression parser on a list of tokens.Result<Expr>
parse(String input)
Applies the expression parser on an input string.
-
-
-
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
-
-