예제 #1
0
class Term(ASTNode):
    # Inherited Attributes
    implicit_pushdown = inherited(implicit_pushdown=True)

    depth = inherited()
    index = inherited()

    # Synthesized Attributes
    index2 = synthesized()
    value = synthesized()
    type = synthesized()

    subtree_depth = synthesized()
    string = synthesized()
    summary = synthesized()

    # Default Rule Implementations
    @synthesized
    def summary(self):
        return "%s, %s" % (self.value, self.type)

    @synthesized
    def index2(self):
        if self.index is None:
            return None

        return self.index * 2

    @pushdown
    def rule_index(self) -> Term.index @ All:
        return None

    @pushdown
    def rule_depth(self) -> Term.depth @ All:
        return self.depth + 1
class SymbolRule:
    child: Optional[SymbolRule]
    node: Optional[SymbolRule]

    attr1 = synthesized()
    attr2 = synthesized()
    test_synthesized = synthesized()

    attr3 = inherited()

    @synthesized
    def attr1(self):
        pass

    @synthesized
    def attr2(self):
        pass

    @synthesized
    def test_synthesized(self, node):
        return node.attr1, node.attr2

    @pushdown
    def test_inheritable(self, node) -> SymbolRule.attr3 @ child:
        return node.attr1, node.attr2

    @pushdown
    def test_inheritable2(self) -> SymbolRule.attr3 @ node:
        pass
예제 #3
0
class Stat:
    ok: bool = synthesized()
    env: dict = inherited()
    same: list = inherited()
예제 #4
0
class Decl:
    new: Tuple[(str, str)] = synthesized()
    env: dict = inherited()
    ok: bool = synthesized()
예제 #5
0
class Block:
    ok: bool = synthesized()
    env: dict = inherited()
    procs: dict = synthesized()
    same: list = inherited()
예제 #6
0
class ChildB:
    attr = inherited()
예제 #7
0
class ChildA:
    child: Optional[ChildB]
    attr = inherited(default="Success")
    listA = inherited(default=[])
    listB = inherited(default=lambda: [])
class NodeBase:
    a: str = inherited(implicit_pushdown=True)