1
0
dust/tree-sitter-dust/corpus/structure.txt

166 lines
4.3 KiB
Plaintext
Raw Normal View History

2023-11-11 01:44:03 +00:00
================================================================================
Simple Structure Definition
2023-11-11 01:44:03 +00:00
================================================================================
struct { answer = 42 }
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
(root
2023-11-11 01:44:03 +00:00
(statement
(expression
(value
(structure_definition
(structure_instantiator
(identifier)
(statement
(expression
(value
(integer))))))))))
2023-12-20 23:29:18 +00:00
================================================================================
Structure Definition with Types
2023-12-20 23:29:18 +00:00
================================================================================
struct {
2023-12-20 23:29:18 +00:00
answer <num> = 42
stuff <[str]> = [ "some" "stuff" ]
}
--------------------------------------------------------------------------------
(root
(statement
(expression
(value
(structure_definition
(structure_instantiator
(identifier)
(type_definition
(type))
(statement
(expression
(value
(integer))))
(identifier)
(type_definition
(type
(type)))
(statement
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(string)))))))))))))
2023-12-20 23:29:18 +00:00
2023-11-11 01:44:03 +00:00
================================================================================
Nested Structure Definition
2023-11-11 01:44:03 +00:00
================================================================================
struct {
bar <Bar>
baz <Baz>
2023-11-28 16:01:38 +00:00
}
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
(root
(statement
(expression
(value
(structure_definition
(structure_instantiator
(identifier)
(type_definition
(type
(identifier)))
(identifier)
(type_definition
(type
(identifier)))))))))
================================================================================
Simple Structure
================================================================================
new Foo
--------------------------------------------------------------------------------
(root
2023-11-11 01:44:03 +00:00
(statement
(expression
(value
(structure
(identifier))))))
================================================================================
Complex Structure
================================================================================
User = struct {
id <int> = random:integer()
email <str>
name <option(str)> = none
}
bob = new User {
email = "bob@example.come"
}
--------------------------------------------------------------------------------
(root
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(structure_definition
(structure_instantiator
(identifier)
(type_definition
(type))
(statement
(expression
(function_call
(function_expression
(index
(index_expression
(value
(built_in_value)))
(index_expression
(identifier)))))))
(identifier)
(type_definition
(type))
(identifier)
(type_definition
(type
(type)))
(statement
(expression
(value
(option)))))))))))
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(structure
(identifier)
(structure_instantiator
(identifier)
(statement
(expression
(value
(string))))))))))))