C# Class Kooboo.Commerce.Rules.Conditions.Parsing.Parser

The parser used to parse the source into expression tree (abstract syntax tree).
Grammer: expression : term [ OR term ]... term : factor [ AND factor ] factor : leaf_condition | ( expression ) comparison : identifier comparison_op comparison_value comparison_op : identifier in the available comparison operator list comparison_value : string_literal | number Notes: - leaf_condition means the condition expression without nesting expressions; - term and factor are temp non-terminals used to handle operator (AND, OR) precedence. Expressions could be simply expressed as: condition OR/AND condition, but with this grammer, we are not able to handle operator precendence. We have to split each operator: - Lower precedence operator first, and the operands should be the production rule of a higher precedence operator. - Because precedence(OR) is smaller than precendence(AND), so OR first and we write: expression: term [ OR term] - Then write the 'term' production rule with the higher precedence operator, that is, 'AND', so then we write: term: factor [ AND factor]
显示文件 Open project: Kooboo/Ecommerce

Public Methods

Method Description
Parse ( string source, IEnumerable registeredComparisonOperators ) : Expression

Private Methods

Method Description
Comparison ( ) : Expression
ComparisonValue ( ) : ComparisonValueExpression
Expression ( ) : Expression
Factor ( ) : Expression
Term ( ) : Expression

Method Details

Parse() public method

public Parse ( string source, IEnumerable registeredComparisonOperators ) : Expression
source string
registeredComparisonOperators IEnumerable
return Kooboo.Commerce.Rules.Conditions.Expressions.Expression