dust/tree-sitter-dust/corpus/functions.txt

282 lines
7.4 KiB
Plaintext
Raw Normal View History

2023-10-31 19:21:13 +00:00
================================================================================
2023-12-12 23:21:16 +00:00
Anonymous Function
2023-10-31 19:21:13 +00:00
================================================================================
2023-12-31 19:04:10 +00:00
() <str> { "Hiya" }
2023-10-31 19:21:13 +00:00
--------------------------------------------------------------------------------
(root
2023-11-11 01:44:03 +00:00
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(value
2024-02-23 04:49:07 +00:00
(anonymous_function
2024-02-16 15:55:15 +00:00
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(value
(string))))))))))))
2023-12-02 03:54:25 +00:00
================================================================================
2023-12-30 01:14:03 +00:00
Function Assignment
2023-12-02 03:54:25 +00:00
================================================================================
2023-12-30 01:14:03 +00:00
foobar = (x <int>, y <int>) <int> {
2023-12-12 23:21:16 +00:00
x + y
}
2023-12-02 03:54:25 +00:00
--------------------------------------------------------------------------------
(root
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(assignment
(identifier)
(assignment_operator)
(statement
(statement_kind
(expression
(value
2024-02-23 04:49:07 +00:00
(anonymous_function
2024-02-16 15:55:15 +00:00
(identifier)
(type_specification
(type))
(identifier)
(type_specification
(type))
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(math
(expression
(identifier))
(math_operator)
(expression
(identifier))))))))))))))))
2023-10-31 22:18:39 +00:00
2023-10-31 19:21:13 +00:00
================================================================================
2023-12-30 01:14:03 +00:00
Identifier Function Call
2023-10-31 19:21:13 +00:00
================================================================================
2023-12-30 01:14:03 +00:00
foobar("Hiya")
2023-10-31 19:21:13 +00:00
--------------------------------------------------------------------------------
(root
2023-11-11 01:44:03 +00:00
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(function_call
(function_expression
(identifier))
(expression
(value
(string))))))))
================================================================================
2023-12-30 01:14:03 +00:00
Index Function Call
================================================================================
2023-12-30 01:14:03 +00:00
foo:bar("Hiya")
--------------------------------------------------------------------------------
(root
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(function_call
(function_expression
(index
(index_expression
(identifier))
(index_expression
(identifier))))
(expression
(value
(string))))))))
2023-12-30 01:14:03 +00:00
================================================================================
Double Function Call
================================================================================
foobar()("Hiya")
--------------------------------------------------------------------------------
(root
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(function_call
(function_expression
(function_call
(function_expression
(identifier))))
(expression
(value
(string))))))))
2023-12-30 01:14:03 +00:00
================================================================================
Anonymous Function Call
================================================================================
(msg <str>) <str> { msg } ("Hiya");
--------------------------------------------------------------------------------
(root
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(function_call
(function_expression
(value
2024-02-23 04:49:07 +00:00
(anonymous_function
2024-02-16 15:55:15 +00:00
(identifier)
(type_specification
(type))
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(identifier))))))))
(expression
(value
(string))))))))
2023-10-31 19:21:13 +00:00
================================================================================
Complex Function Call
2023-10-31 19:21:13 +00:00
================================================================================
2023-12-30 01:14:03 +00:00
foobar(
"hi"
42
2023-11-28 16:01:38 +00:00
{
x = 1
y = 2
2023-11-28 16:01:38 +00:00
}
)
2023-10-31 19:21:13 +00:00
--------------------------------------------------------------------------------
(root
2023-11-11 01:44:03 +00:00
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(function_call
(function_expression
(identifier))
(expression
(value
(string)))
(expression
(value
(integer)))
(expression
(value
(map
(identifier)
(statement
(statement_kind
(expression
(value
(integer)))))
(identifier)
(statement
(statement_kind
(expression
(value
(integer)))))))))))))
2023-12-15 22:27:29 +00:00
================================================================================
Callback Function Call
================================================================================
2023-12-30 01:14:03 +00:00
x(() <bool> { true })
2023-12-15 22:27:29 +00:00
--------------------------------------------------------------------------------
(root
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(function_call
(function_expression
(identifier))
(expression
(value
2024-02-23 04:49:07 +00:00
(anonymous_function
2024-02-16 15:55:15 +00:00
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(value
(boolean))))))))))))))
================================================================================
Nested Function Call
================================================================================
2023-12-30 01:14:03 +00:00
from_json(read('file.json'))
--------------------------------------------------------------------------------
(root
(statement
2024-02-16 15:55:15 +00:00
(statement_kind
(expression
(function_call
(function_expression
(identifier))
(expression
(function_call
(function_expression
(identifier))
(expression
(value
(string))))))))))
2024-02-23 04:49:07 +00:00
================================================================================
Function Definition
================================================================================
fn foo<T> (bar <T>) <T> {
bar
}
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(type_definition
(function_definition
(identifier)
(type_arguments
(type
(identifier)))
(identifier)
(type_specification
(type
(identifier)))
(type_specification
(type
(identifier)))
(block
(statement
(statement_kind
(expression
(identifier))))))))))