Create expression3 (logic 'and') and expression4 (logic 'or') precedence

This commit is contained in:
Bartłomiej Pluta
2019-07-10 22:46:58 +02:00
parent 3058293b7e
commit 175bea6e5c
4 changed files with 16 additions and 2 deletions

View File

@@ -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):

View File

@@ -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: