Refactor LeftAssociativeOperatorNode

This commit is contained in:
Bartłomiej Pluta
2019-07-10 17:02:18 +02:00
parent 214eec0e7a
commit 76eabbff0e
9 changed files with 35 additions and 18 deletions

View File

@@ -45,22 +45,23 @@ class LeftAssociativeOperatorNode(ExpressionNode):
return node
return Parser.leftAssociativeOperatorParser(
cls._literalParser(),
cls._lhsParser(),
TokenType.DOT,
cls._parseAccessingProperty(),
cls._rhsParser(),
createNode=createNode
)(input)
@classmethod
def _literalParser(cls):
pass
def _lhsParser(cls):
raise RuntimeError(f"LHS parser is not implemented in {cls.__name__}")
@staticmethod
def _parseAccessingProperty():
def _rhsParser():
from smnp.ast.node.identifier import IdentifierNode
return Parser.oneOf(
IdentifierNode._literalParser(),
# TODO!!!
IdentifierNode._lhsParser(),
IdentifierNode._functionCallParser(),
exception=lambda input: SyntaxException(f"Expected property name or method call, found '{input.current().rawValue}'", input.currentPos())
)