Example #1
0
 class BarNode(FooNode):
     _prop = Property(No(FooNode))
Example #2
0
 class Example(FooNode):
     result = Property(prop)
Example #3
0
class FooNode(ASTNode):
    id_bool = Property(lambda id=T.Bool: id, public=True)
    id_int = Property(lambda id=T.Int: id, public=True)
    id_bigint = Property(lambda id=T.BigInt: id, public=True)
    id_char = Property(lambda id=T.Character: id, public=True)
    id_token = Property(lambda id=T.Token: id, public=True)
    id_sym = Property(lambda id=T.Symbol: id, public=True)
    id_unit = Property(lambda id=T.AnalysisUnit: id, public=True)
    id_root_node = Property(lambda id=T.FooNode: id, public=True)
    id_name = Property(lambda id=T.Name: id, public=True)

    # Test for enums
    id_unit_kind = Property(lambda id=T.AnalysisUnitKind: id, public=True)

    # Test for arrays
    id_node_array = Property(lambda id=T.FooNode.entity.array: id, public=True)
    id_bigint_array = Property(lambda id=T.BigInt.array: id, public=True)
Example #4
0
class Ref(Atom):
    token_node = True

    prop1 = Property(3)
    prop2 = Property(3)
    prop3 = Property(3)
Example #5
0
class FuncDecl(Decl):
    name = Field()
    args = Field()
    expr = Field()

    decl_kind = Property(DeclKind.func)
Example #6
0
 class BarNode(FooNode):
     prop_2 = Property(lambda x=LongType: x)
     prop = Property(expr)
Example #7
0
class Atom(Expr):

    # Warning: both concrete subclasses override this (concrete derived
    # property).
    prop1 = Property(1)
Example #8
0
    class Name(FooNode):
        token_node = True

    class Decl(FooNode):
        name = Field()
        refs = Field()

        env_spec = EnvSpec(add_to_env_kv(key=Self.name.symbol, value=Self),
                           add_env())

    class Ref(FooNode):
        name = Field()

        env_spec = EnvSpec(
            add_to_env_kv(key=Self.name.symbol,
                          value=Self,
                          resolver=FooNode.resolve_ref))

        @langkit_property(public=True)
        def resolve():
            return Self.node_env.get(Self.name).at(0)

    emit_and_print_errors(lkt_file='foo.lkt')


run('Bad return type', Property(Self.node_env.get('foo')))
run('Has dynamic variable',
    Property(Self.node_env.get('foo').at(0), dynamic_vars=[Env]))
run('Has arguments', Property(lambda i=T.Int: Self.node_env.get('foo').at(i)))
print('Done')
Example #9
0
 class Example(FooNode):
     p = Property(expr)
     calling = Property(calling_expr)
Example #10
0
 class BarNode(FooNode):
     prop = Property(expr, public=True)
Example #11
0
class Id(Name):
    token_node = True

    sym = Property(
        Self.symbol, doc="Shortcut to get the symbol of this node"
    )
Example #12
0
 class Example(FooNode):
     token_node = True
     p = Property(expr.symbol, public=True)
Example #13
0
 class ExampleNode(MiddleNode):
     get_random_node = Property(No(astnode))
Example #14
0
 class LiteralList(Literal.list):
     prop = Property(prop_fn(), memoized=prop_memoized)
Example #15
0
class Decl(FooNode):
    decl_kind = AbstractProperty(DeclKind, public=True)
    with_kind = Property(DeclAndKind.new(dcl=Self, knd=Self.decl_kind),
                         public=True)
Example #16
0
 class BarNode(FooNode):
     prop = Property(prop_lambda, warn_on_unused=False)
Example #17
0
class ListNode(FooNode):
    nb_list = Field()
    prop = Property(Self.nb_list.map(lambda i, _: i), public=True)
Example #18
0
class FooNode(ASTNode):
    root_node = Property(Self.unit.root.as_bare_entity, public=True)
Example #19
0
 class ListNode(FooNode):
     nb_list = Field()
     prop = Property(expr, public=True)
Example #20
0
class Sequence(FooNode.list):
    all_items = Property(Entity.map(lambda i: i), public=True)
    example_items = Property(Entity.filtermap(
        lambda i: i.cast_or_raise(T.Example), lambda i: i.is_a(T.Example)),
                             public=True)
Example #21
0
class Lit(Atom):
    token_node = True

    prop1 = Property(2)
    prop2 = Property(2)
    prop3 = Property(2)
Example #22
0
class Example(FooNode):
    prop = Property(True, public=True)
Example #23
0
class VarDecl(Decl):
    name = Field()
    expr = Field()

    decl_kind = Property(DeclKind.var)
Example #24
0
 class FooNode(ASTNode):
     prop = Property(Literal(0), public=True)
Example #25
0
 class ExampleNode(FooNode):
     b = Property(lit, public=True)
Example #26
0
    class ExampleNode(FooNode):
        body = Field()

        prop = Property(match_expr)
Example #27
0
class Plus(Expression):
    left = Field()
    right = Field()

    result = Property(Self.left.result + Self.right.result)
Example #28
0
class BarNode(BarCode):
    base_prop = Property(lambda x=Symbol: 12)
Example #29
0
 class BarNode(FooNode):
     prop_2 = Property(lambda x=Int: x, public=True)
     prop = Property(expr, public=True)
Example #30
0
class Example(FooNode):
    get_num = Property(2)