Create expression precendence level

This commit is contained in:
Bartłomiej Pluta
2019-07-10 22:27:44 +02:00
parent 1d573c8c80
commit 4018bcddc7
10 changed files with 390 additions and 346 deletions

View File

@@ -1,11 +1,12 @@
from smnp.ast.node.factor import FactorParser
from smnp.ast.node.operator import BinaryOperator
from smnp.ast.node.valuable import Valuable
from smnp.ast.parser import Parser
from smnp.token.type import TokenType
class Term(BinaryOperator):
class Term(Valuable):
pass
TermParser = Parser.leftAssociativeOperatorParser(FactorParser, [TokenType.ASTERISK, TokenType.SLASH], FactorParser,
lambda left, op, right: Term.withValues(left, op, right))
lambda left, op, right: Term.withValue(BinaryOperator.withValues(left, op, right)))