2024-10-14 09:47:37 +00:00
|
|
|
# Check that passing structs as property argument and returning structs works
|
|
|
|
|
# as expected.
|
|
|
|
|
|
2026-01-13 14:49:31 +00:00
|
|
|
from lexer_example import foo_lexer
|
2023-05-15 13:27:40 +02:00
|
|
|
|
|
|
|
|
@with_lexer(foo_lexer)
|
|
|
|
|
grammar foo_grammar {
|
2024-06-20 11:22:42 +00:00
|
|
|
@main_rule main_rule <- Example(@Example)
|
2023-05-15 13:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2024-06-27 17:49:11 +02:00
|
|
|
@abstract
|
|
|
|
|
class FooNode implements Node[FooNode] {
|
2023-05-15 13:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-22 09:47:18 +00:00
|
|
|
class Example: FooNode implements TokenNode {
|
2024-06-27 17:49:11 +02:00
|
|
|
@exported
|
|
|
|
|
fun sum(s: MyStruct): Int = s.a + s.b
|
2023-05-15 13:27:40 +02:00
|
|
|
|
2024-06-27 17:49:11 +02:00
|
|
|
@exported
|
|
|
|
|
fun create(a: Int, b: Int): MyStruct = MyStruct(a=a, b=b)
|
2023-05-15 13:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct MyStruct {
|
|
|
|
|
a: Int
|
|
|
|
|
b: Int
|
|
|
|
|
}
|