Exemplo n.º 1
0
 class BarNode(FooNode):
     _prop = Property(No(FooNode))
Exemplo n.º 2
0
 class Example(FooNode):
     result = Property(prop)
Exemplo n.º 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)
Exemplo n.º 4
0
class Ref(Atom):
    token_node = True

    prop1 = Property(3)
    prop2 = Property(3)
    prop3 = Property(3)
Exemplo n.º 5
0
class FuncDecl(Decl):
    name = Field()
    args = Field()
    expr = Field()

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

    # Warning: both concrete subclasses override this (concrete derived
    # property).
    prop1 = Property(1)
Exemplo n.º 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')
Exemplo n.º 9
0
 class Example(FooNode):
     p = Property(expr)
     calling = Property(calling_expr)
Exemplo n.º 10
0
 class BarNode(FooNode):
     prop = Property(expr, public=True)
Exemplo n.º 11
0
class Id(Name):
    token_node = True

    sym = Property(
        Self.symbol, doc="Shortcut to get the symbol of this node"
    )
Exemplo n.º 12
0
 class Example(FooNode):
     token_node = True
     p = Property(expr.symbol, public=True)
Exemplo n.º 13
0
 class ExampleNode(MiddleNode):
     get_random_node = Property(No(astnode))
Exemplo n.º 14
0
 class LiteralList(Literal.list):
     prop = Property(prop_fn(), memoized=prop_memoized)
Exemplo n.º 15
0
class Decl(FooNode):
    decl_kind = AbstractProperty(DeclKind, public=True)
    with_kind = Property(DeclAndKind.new(dcl=Self, knd=Self.decl_kind),
                         public=True)
Exemplo n.º 16
0
 class BarNode(FooNode):
     prop = Property(prop_lambda, warn_on_unused=False)
Exemplo n.º 17
0
class ListNode(FooNode):
    nb_list = Field()
    prop = Property(Self.nb_list.map(lambda i, _: i), public=True)
Exemplo n.º 18
0
class FooNode(ASTNode):
    root_node = Property(Self.unit.root.as_bare_entity, public=True)
Exemplo n.º 19
0
 class ListNode(FooNode):
     nb_list = Field()
     prop = Property(expr, public=True)
Exemplo n.º 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)
Exemplo n.º 21
0
class Lit(Atom):
    token_node = True

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

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

        prop = Property(match_expr)
Exemplo n.º 27
0
class Plus(Expression):
    left = Field()
    right = Field()

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