tree-sitter-elixir/test/corpus/expression/call.txt

988 lines
15 KiB
Plaintext

=====================================
local call / no arguments
=====================================
fun()
---
(source
(call
(identifier)
(arguments)))
=====================================
local call / arguments in parentheses
=====================================
fun(a)
fun([1, 2], option: true, other: 5)
---
(source
(call
(identifier)
(arguments
(identifier)))
(call
(identifier)
(arguments
(list
(integer)
(integer))
(keywords
(pair
(keyword)
(boolean))
(pair
(keyword)
(integer))))))
=====================================
local call / arguments without parentheses
=====================================
fun a
fun {}
fun [1, 2], option: true, other: 5
fun +: 1
---
(source
(call
(identifier)
(arguments
(identifier)))
(call
(identifier)
(arguments
(tuple)))
(call
(identifier)
(arguments
(list
(integer)
(integer))
(keywords
(pair
(keyword)
(boolean))
(pair
(keyword)
(integer)))))
(call
(identifier)
(arguments
(keywords
(pair
(keyword)
(integer))))))
=====================================
local call / arguments without parentheses / multiline
=====================================
fun [1, 2],
option: true,
other: 5
---
(source
(call
(identifier)
(arguments
(list
(integer)
(integer))
(keywords
(pair
(keyword)
(boolean))
(pair
(keyword)
(integer))))))
=====================================
local call / nested with parentheses
=====================================
outer_fun(inner_fun(a))
---
(source
(call
(identifier)
(arguments
(call
(identifier)
(arguments
(identifier))))))
=====================================
local call / nested without parentheses (right associativity)
=====================================
outer_fun inner_fun a, b
outer_fun inner_fun do: 1
---
(source
(call
(identifier)
(arguments
(call
(identifier)
(arguments
(identifier)
(identifier)))))
(call
(identifier)
(arguments
(call
(identifier)
(arguments
(keywords
(pair
(keyword)
(integer))))))))
=====================================
local call / precedence with operator
=====================================
outer_fun 1 + 1
1 + inner_fun 1
outer_fun 1 + inner_fun 1
fun 1, 2 |> other_fun
---
(source
(call
(identifier)
(arguments
(binary_operator
(integer)
(integer))))
(binary_operator
(integer)
(call
(identifier)
(arguments
(integer))))
(call
(identifier)
(arguments
(binary_operator
(integer)
(call
(identifier)
(arguments
(integer))))))
(call
(identifier)
(arguments
(integer)
(binary_operator
(integer)
(identifier)))))
=====================================
local call / treats nonimmediate parentheses as a block argument
=====================================
fun (x)
---
(source
(call
(identifier)
(arguments
(block
(identifier)))))
=====================================
remote call / no arguments
=====================================
Mod.fun()
---
(source
(call
(dot
(alias)
(identifier))
(arguments)))
=====================================
remote call / no arguments without parentheses
=====================================
Mod.fun
---
(source
(call
(dot
(alias)
(identifier))))
=====================================
remote call / arguments in parentheses
=====================================
Mod.fun(a)
Mod.fun([1, 2], option: true, other: 5)
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(identifier)))
(call
(dot
(alias)
(identifier))
(arguments
(list
(integer)
(integer))
(keywords
(pair
(keyword)
(boolean))
(pair
(keyword)
(integer))))))
=====================================
remote call / arguments without parentheses
=====================================
Mod.fun a
Mod.fun [1, 2], option: true, other: 5
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(identifier)))
(call
(dot
(alias)
(identifier))
(arguments
(list
(integer)
(integer))
(keywords
(pair
(keyword)
(boolean))
(pair
(keyword)
(integer))))))
=====================================
remote call / nested with parentheses
=====================================
Mod.outer_fun(Mod.inner_fun(a))
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(call
(dot
(alias)
(identifier))
(arguments
(identifier))))))
=====================================
remote call / nested without parentheses (right associativity)
=====================================
Mod.outer_fun Mod.inner_fun a
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(call
(dot
(alias)
(identifier))
(arguments
(identifier))))))
=====================================
remote call / precedence with operator
=====================================
Mod.outer_fun 1 + 1
1 + Mod.inner_fun 1
Mod.outer_fun 1 + Mod.inner_fun 1
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(binary_operator
(integer)
(integer))))
(binary_operator
(integer)
(call
(dot
(alias)
(identifier))
(arguments
(integer))))
(call
(dot
(alias)
(identifier))
(arguments
(binary_operator
(integer)
(call
(dot
(alias)
(identifier))
(arguments
(integer)))))))
=====================================
remote call / treats nonimmediate parentheses as a block argument
=====================================
Mod.fun (x)
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(block
(identifier)))))
=====================================
remote call / multi-level alias
=====================================
Mod1.Mod2.Mod3.fun(a)
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(identifier))))
=====================================
remote call / operator
=====================================
Kernel.+(a, b)
---
(source
(call
(dot
(alias)
(operator_identifier))
(arguments
(identifier)
(identifier))))
=====================================
remote call / quoted function name
=====================================
Mod."fun"(a)
Mod.'fun'(a)
---
(source
(call
(dot
(alias)
(string
(quoted_content)))
(arguments
(identifier)))
(call
(dot
(alias)
(charlist
(quoted_content)))
(arguments
(identifier))))
=====================================
remote call / atom literal module
=====================================
:mod.fun(a)
:"Elixir.Mod".fun(a)
---
(source
(call
(dot
(atom)
(identifier))
(arguments
(identifier)))
(call
(dot
(quoted_atom
(quoted_content))
(identifier))
(arguments
(identifier))))
=====================================
anonymous call / no arguments
=====================================
fun.()
---
(source
(call
(dot
(identifier))
(arguments)))
=====================================
anonymous call / arguments in parentheses
=====================================
fun.(a)
fun.([1, 2], option: true, other: 5)
---
(source
(call
(dot
(identifier))
(arguments
(identifier)))
(call
(dot
(identifier))
(arguments
(list
(integer)
(integer))
(keywords
(pair
(keyword)
(boolean))
(pair
(keyword)
(integer))))))
=====================================
anonymous call / nested with parentheses
=====================================
outer_fun.(inner_fun.(a))
---
(source
(call
(dot
(identifier))
(arguments
(call
(dot
(identifier))
(arguments
(identifier))))))
=====================================
mixed call types
=====================================
Mod.outer_fun mid_fun inner_fun.(a)
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(call
(identifier)
(arguments
(call
(dot
(identifier))
(arguments
(identifier))))))))
=====================================
identifier call
=====================================
mod.fun(a)
---
(source
(call
(dot
(identifier)
(identifier))
(arguments
(identifier))))
=====================================
nested identifier call
=====================================
map.mod.fun(a)
---
(source
(call
(dot
(call
(dot
(identifier)
(identifier)))
(identifier))
(arguments
(identifier))))
=====================================
reserved word call
=====================================
a.and
---
(source
(call
(dot
(identifier)
(identifier))))
=====================================
range call
=====================================
(1..2).step
(1..2//3).step
---
(source
(call
(dot
(block
(binary_operator
(integer)
(integer)))
(identifier)))
(call
(dot
(block
(binary_operator
(binary_operator
(integer)
(integer))
(integer)))
(identifier))))
=====================================
multi-expression block call
=====================================
(
x
1..2
).step
---
(source
(call
(dot
(block
(identifier)
(binary_operator
(integer)
(integer)))
(identifier))))
=====================================
map call
=====================================
%{}.field
---
(source
(call
(dot
(map)
(identifier))))
=====================================
struct call
=====================================
%Mod{}.field
---
(source
(call
(dot
(map
(struct
(alias)))
(identifier))))
=====================================
arbitrary term call
=====================================
1.(1, 2)
---
(source
(call
(dot
(integer))
(arguments
(integer)
(integer))))
=====================================
escaped newline call
=====================================
fun \
a
---
(source
(call
(identifier)
(arguments
(identifier))))
=====================================
keyword list trailing separator
=====================================
fun(option: true, other: 5,)
---
(source
(call
(identifier)
(arguments
(keywords
(pair
(keyword)
(boolean))
(pair
(keyword)
(integer))))))
=====================================
newline before dot
=====================================
Mod
.fun(a)
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(identifier))))
=====================================
newline after dot
=====================================
Mod.
fun(a)
---
(source
(call
(dot
(alias)
(identifier))
(arguments
(identifier))))
=====================================
access syntax
=====================================
map[key]
map[:key]
---
(source
(access_call
(identifier)
(identifier))
(access_call
(identifier)
(atom)))
=====================================
access syntax / does not allow whitespace
=====================================
map [key]
---
(source
(call
(identifier)
(arguments
(list
(identifier)))))
=====================================
access syntax / precedence with dot call
=====================================
map.map[:key]
map[:mod].fun
---
(source
(access_call
(call
(dot
(identifier)
(identifier)))
(atom))
(call
(dot
(access_call
(identifier)
(atom))
(identifier))))
=====================================
access syntax / precedence with operators
=====================================
-x[:key]
@x[:key]
&x[:key]
&1[:key]
---
(source
(unary_operator
(access_call
(identifier)
(atom)))
(access_call
(unary_operator
(identifier))
(atom))
(unary_operator
(access_call
(identifier)
(atom)))
(access_call
(unary_operator
(integer))
(atom)))
=====================================
double parenthesised call
=====================================
fun()()
fun() ()
fun(1)(1)
Mod.fun()()
fun.()()
unquote(name)()
---
(source
(call
(call
(identifier)
(arguments))
(arguments))
(call
(call
(identifier)
(arguments))
(arguments))
(call
(call
(identifier)
(arguments
(integer)))
(arguments
(integer)))
(call
(call
(dot
(alias)
(identifier))
(arguments))
(arguments))
(call
(call
(dot
(identifier))
(arguments))
(arguments))
(call
(call
(identifier)
(arguments
(identifier)))
(arguments)))
=====================================
[field names]
=====================================
fun()
fun a
Mod.fun a
fun()()
fun.()
map[key]
---
(source
(call
target: (identifier)
(arguments))
(call
target: (identifier)
(arguments
(identifier)))
(call
target: (dot
left: (alias)
right: (identifier))
(arguments
(identifier)))
(call
target: (call
target: (identifier)
(arguments))
(arguments))
(call
target: (dot
left: (identifier))
(arguments))
(access_call
target: (identifier)
key: (identifier)))
=====================================
[error] leading argument separator
=====================================
fun(, a)
---
(source
(call
(identifier)
(arguments
(ERROR)
(identifier))))
=====================================
[error] trailing argument separator
=====================================
fun(a,)
---
(source
(call
(identifier)
(arguments
(identifier)
(ERROR))))