Create almost working proof of concept with new parsers
This commit is contained in:
@@ -1,21 +1,31 @@
|
||||
from smnp.ast.node.atom import AtomParser
|
||||
from smnp.ast.node.list import ListParser
|
||||
from smnp.ast.node.map import MapParser
|
||||
from smnp.ast.node.operator import BinaryOperator
|
||||
from smnp.ast.node.valuable import Valuable
|
||||
from smnp.ast.parser import Parser
|
||||
from smnp.ast.parser import Parsers
|
||||
from smnp.token.type import TokenType
|
||||
from smnp.util.singleton import SingletonParser
|
||||
|
||||
|
||||
class Chain(Valuable):
|
||||
pass
|
||||
|
||||
itemParser = Parser.oneOf(
|
||||
ListParser,
|
||||
MapParser,
|
||||
AtomParser,
|
||||
)
|
||||
|
||||
ChainParser = Parser.leftAssociativeOperatorParser(itemParser, [TokenType.DOT], itemParser,
|
||||
lambda left, op, right: Chain.withValue(BinaryOperator.withValues(left, op, right)))
|
||||
|
||||
@SingletonParser
|
||||
def ChainParser():
|
||||
from smnp.ast.node.atom import AtomParser
|
||||
|
||||
itemParser = Parsers.oneOf(
|
||||
#ListParser,
|
||||
#MapParser,
|
||||
AtomParser,
|
||||
name="chainItem"
|
||||
)
|
||||
|
||||
return Parsers.leftAssociativeOperatorParser(
|
||||
itemParser,
|
||||
[TokenType.DOT],
|
||||
itemParser,
|
||||
lambda left, op, right: Chain.withValue(BinaryOperator.withValues(left, op, right)),
|
||||
name="chain"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user