186 lines
4.4 KiB
Plaintext
186 lines
4.4 KiB
Plaintext
================================================================================
|
|
Simple Function
|
|
================================================================================
|
|
|
|
fn || { "Hiya" }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(expression
|
|
(value
|
|
(function
|
|
(block
|
|
(statement
|
|
(expression
|
|
(value
|
|
(string))))))))))
|
|
|
|
================================================================================
|
|
Function Assignment
|
|
================================================================================
|
|
|
|
foobar <(str) -> str> = fn |text| { text }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(assignment
|
|
(identifier)
|
|
(type_definition
|
|
(type
|
|
(type)
|
|
(type)))
|
|
(assignment_operator)
|
|
(statement
|
|
(expression
|
|
(value
|
|
(function
|
|
(identifier)
|
|
(block
|
|
(statement
|
|
(expression
|
|
(identifier)))))))))))
|
|
|
|
================================================================================
|
|
Function Call
|
|
================================================================================
|
|
|
|
(foobar "Hiya")
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(expression
|
|
(function_call
|
|
(expression
|
|
(identifier))
|
|
(expression
|
|
(value
|
|
(string)))))))
|
|
|
|
================================================================================
|
|
Complex Function
|
|
================================================================================
|
|
|
|
fn |message number| {
|
|
(output message)
|
|
(output number)
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(expression
|
|
(value
|
|
(function
|
|
(identifier)
|
|
(identifier)
|
|
(block
|
|
(statement
|
|
(expression
|
|
(function_call
|
|
(expression
|
|
(identifier))
|
|
(expression
|
|
(identifier)))))
|
|
(statement
|
|
(expression
|
|
(function_call
|
|
(expression
|
|
(identifier))
|
|
(expression
|
|
(identifier)))))))))))
|
|
|
|
================================================================================
|
|
Complex Function Call
|
|
================================================================================
|
|
|
|
(foobar
|
|
"hi"
|
|
42
|
|
{
|
|
x = 1
|
|
y = 2
|
|
}
|
|
)
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(expression
|
|
(function_call
|
|
(expression
|
|
(identifier))
|
|
(expression
|
|
(value
|
|
(string)))
|
|
(expression
|
|
(value
|
|
(integer)))
|
|
(expression
|
|
(value
|
|
(map
|
|
(identifier)
|
|
(statement
|
|
(expression
|
|
(value
|
|
(integer))))
|
|
(identifier)
|
|
(statement
|
|
(expression
|
|
(value
|
|
(integer)))))))))))
|
|
|
|
================================================================================
|
|
Callback Function
|
|
================================================================================
|
|
|
|
foobar <(() -> str) -> str> = fn |cb| {
|
|
(cb)
|
|
}
|
|
|
|
(foobar fn || { 'Hiya' })
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(assignment
|
|
(identifier)
|
|
(type_definition
|
|
(type
|
|
(type
|
|
(type))
|
|
(type)))
|
|
(assignment_operator)
|
|
(statement
|
|
(expression
|
|
(value
|
|
(function
|
|
(identifier)
|
|
(block
|
|
(statement
|
|
(expression
|
|
(function_call
|
|
(expression
|
|
(identifier))))))))))))
|
|
(statement
|
|
(expression
|
|
(function_call
|
|
(expression
|
|
(identifier))
|
|
(expression
|
|
(value
|
|
(function
|
|
(block
|
|
(statement
|
|
(expression
|
|
(value
|
|
(string))))))))))))
|