Create expression3 (logic 'and') and expression4 (logic 'or') precedence
This commit is contained in:
@@ -14,6 +14,14 @@ ExpressionParser = Parser.leftAssociativeOperatorParser(TermParser, [TokenType.P
|
||||
Expression2Parser = Parser.leftAssociativeOperatorParser(ExpressionParser, [TokenType.RELATION], ExpressionParser,
|
||||
lambda left, op, right: Expression.withValue(BinaryOperator.withValues(left, op, right)))
|
||||
|
||||
Expression3Parser = Parser.leftAssociativeOperatorParser(Expression2Parser, [TokenType.AND], Expression2Parser,
|
||||
lambda left, op, right: Expression.withValue(BinaryOperator.withValues(left, op, right)))
|
||||
|
||||
Expression4Parser = Parser.leftAssociativeOperatorParser(Expression3Parser, [TokenType.OR], Expression3Parser,
|
||||
lambda left, op, right: Expression.withValue(BinaryOperator.withValues(left, op, right)))
|
||||
|
||||
MaxPrecedenceExpressionParser = Expression4Parser
|
||||
|
||||
#
|
||||
# class ExpressionNode(Node):
|
||||
# def __init__(self, pos):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from smnp.ast.node.expression import Expression2Parser
|
||||
from smnp.ast.node.expression import MaxPrecedenceExpressionParser
|
||||
from smnp.ast.node.model import Node, ParseResult
|
||||
from smnp.ast.parser import Parser
|
||||
|
||||
@@ -15,7 +15,7 @@ def parse(input):
|
||||
|
||||
|
||||
#TODO -> temporary (to remove):
|
||||
Expression2Parser
|
||||
MaxPrecedenceExpressionParser
|
||||
)(input)
|
||||
|
||||
if result.result:
|
||||
|
||||
Reference in New Issue
Block a user