Working proof of concept of multiple left associative operators
This commit is contained in:
@@ -27,7 +27,7 @@ class AccessNode(ExpressionNode):
|
||||
self[1] = value
|
||||
|
||||
@classmethod
|
||||
def _parse(cls, input):
|
||||
def accessParser(cls):
|
||||
def createNode(left, right):
|
||||
node = AccessNode(right.pos)
|
||||
node.left = left
|
||||
@@ -35,22 +35,22 @@ class AccessNode(ExpressionNode):
|
||||
return node
|
||||
|
||||
return Parser.leftAssociativeOperatorParser(
|
||||
cls._literalParser(),
|
||||
cls._accessLiteralParser(),
|
||||
TokenType.DOT,
|
||||
cls._parseAccessingProperty(),
|
||||
createNode=createNode
|
||||
)(input)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _literalParser(cls):
|
||||
pass
|
||||
def _accessLiteralParser(cls):
|
||||
raise RuntimeError(f"_accessLiteralParser() is not implemented in {cls.__name__} class")
|
||||
|
||||
@staticmethod
|
||||
def _parseAccessingProperty():
|
||||
from smnp.ast.node.identifier import IdentifierNode
|
||||
|
||||
return Parser.oneOf(
|
||||
IdentifierNode._literalParser(),
|
||||
IdentifierNode.identifierParser(),
|
||||
IdentifierNode._functionCallParser(),
|
||||
exception=lambda input: SyntaxException(f"Expected property name or method call, found '{input.current().rawValue}'", input.currentPos())
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user