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

250 lines
6.6 KiB
Plaintext

================================================================================
Anonymous Function
================================================================================
() <str> { "Hiya" }
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(expression
(value
(anonymous_function
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(value
(string))))))))))))
================================================================================
Function Assignment
================================================================================
foobar = (x <int>, y <int>) <int> {
x + y
}
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(assignment
(identifier)
(assignment_operator)
(statement
(statement_kind
(expression
(value
(anonymous_function
(identifier)
(type_specification
(type))
(identifier)
(type_specification
(type))
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(math
(expression
(identifier))
(math_operator)
(expression
(identifier))))))))))))))))
================================================================================
Identifier Function Call
================================================================================
foobar("Hiya")
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(expression
(function_call
(function_expression
(identifier))
(expression
(value
(string))))))))
================================================================================
Index Function Call
================================================================================
foo:bar("Hiya")
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(expression
(function_call
(function_expression
(index
(index_expression
(identifier))
(index_expression
(identifier))))
(expression
(value
(string))))))))
================================================================================
Double Function Call
================================================================================
foobar()("Hiya")
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(expression
(function_call
(function_expression
(function_call
(function_expression
(identifier))))
(expression
(value
(string))))))))
================================================================================
Anonymous Function Call
================================================================================
(msg <str>) <str> { msg } ("Hiya");
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(expression
(function_call
(function_expression
(value
(anonymous_function
(identifier)
(type_specification
(type))
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(identifier))))))))
(expression
(value
(string))))))))
================================================================================
Complex Function Call
================================================================================
foobar(
"hi"
42
{
x = 1
y = 2
}
)
--------------------------------------------------------------------------------
(root
(statement
(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)))))))))))))
================================================================================
Callback Function Call
================================================================================
x(() <bool> { true })
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(expression
(function_call
(function_expression
(identifier))
(expression
(value
(anonymous_function
(type_specification
(type))
(block
(statement
(statement_kind
(expression
(value
(boolean))))))))))))))
================================================================================
Nested Function Call
================================================================================
from_json(read('file.json'))
--------------------------------------------------------------------------------
(root
(statement
(statement_kind
(expression
(function_call
(function_expression
(identifier))
(expression
(function_call
(function_expression
(identifier))
(expression
(value
(string))))))))))