tree-sitter-d2/test/corpus/container.txt

310 lines
6.1 KiB
Text

================================================================================
Declare a shape inside a container
================================================================================
foo.baz
foo.bar.biz
--------------------------------------------------------------------------------
(source_file
(container
(container_key) (dot)
(shape (shape_key))
)
(container
(container_key) (dot)
(container
(container_key) (dot)
(shape (shape_key))
)
)
)
================================================================================
Use quoted string as keys
================================================================================
'foo'.'baz'
--------------------------------------------------------------------------------
(source_file
(container
(container_key (string (string_fragment))) (dot)
(shape (shape_key (string (string_fragment))))
)
)
================================================================================
Declare container inside a container using block
================================================================================
foo: {
bar: {
baz: {
biz
}
}
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(block
(container
(container_key)
(colon)
(block
(container
(container_key)
(colon)
(block
(shape (shape_key))
)
)
)
)
)
)
)
================================================================================
Declare labeled container inside a labeled container using block
================================================================================
foo: Foo {
bar: Bar {
baz: Baz {
biz: Biz
}
}
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(label)
(block
(container
(container_key)
(colon)
(label)
(block
(container
(container_key)
(colon)
(label)
(block
(shape (shape_key) (colon) (label))
)
)
)
)
)
)
)
================================================================================
Declare many shapes inside a container
================================================================================
foo: {
bar
biz
baz
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(block
(shape (shape_key))
(shape (shape_key))
(shape (shape_key))
)
)
)
================================================================================
Declare a container with complex keys
================================================================================
Foo biz bar: {
bar biz baz: {
-biz-baz-Baz-: {
Helo world
}
}
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(block
(container
(container_key)
(colon)
(block
(container
(container_key)
(colon)
(block
(shape (shape_key))
)
)
)
)
)
)
)
================================================================================
Declare a container with complex keys and labels
================================================================================
Foo biz bar: Biz biz Bar {
bar biz baz: baz baz biz {
-biz-baz-Baz-: Biz buz Baz {
Helo world
}
}
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(label)
(block
(container
(container_key)
(colon)
(label)
(block
(container
(container_key)
(colon)
(label)
(block
(shape (shape_key))
)
)
)
)
)
)
)
================================================================================
Declare shapes sparsely in a container
================================================================================
Foo: Baz {
biz
baz
bar
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(label)
(block
(shape (shape_key))
(shape (shape_key))
(shape (shape_key))
)
)
)
================================================================================
Declare shapes in a container in single-line (Issue #11)
================================================================================
primty: Primitive types {
Never: {"!"}
Boolean: {bool}
Textual: {char; str}
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(label)
(block
(container
(container_key)
(colon)
(block
(shape
(shape_key (string (string_fragment)))
)
)
)
(container
(container_key)
(colon)
(block
(shape (shape_key))
)
)
(container
(container_key)
(colon)
(block
(shape (shape_key))
(shape (shape_key))
)
)
)
)
)
================================================================================
Declare a container with a references to the parent container
================================================================================
container: {
_.foo: baz
}
--------------------------------------------------------------------------------
(source_file
(container
(container_key)
(colon)
(block
(container
(container_key (keyword_underscore))
(dot)
(shape (shape_key) (colon) (label))
)
)
)
)