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

988 lines
15 KiB
Plaintext
Raw Normal View History

2021-09-01 14:59:04 +00:00
=====================================
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
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(boolean))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(integer))))))
=====================================
local call / arguments without parentheses
=====================================
fun a
2021-09-25 00:23:37 +00:00
fun {}
2021-09-01 14:59:04 +00:00
fun [1, 2], option: true, other: 5
2021-09-25 00:23:37 +00:00
fun +: 1
2021-09-01 14:59:04 +00:00
---
(source
(call
(identifier)
(arguments
(identifier)))
2021-09-25 00:23:37 +00:00
(call
(identifier)
(arguments
(tuple)))
(call
(identifier)
(arguments
(list
(integer)
(integer))
(keywords
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-25 00:23:37 +00:00
(boolean))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-25 00:23:37 +00:00
(integer)))))
(call
(identifier)
(arguments
(keywords
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-25 00:23:37 +00:00
(integer))))))
=====================================
local call / arguments without parentheses / multiline
=====================================
fun [1, 2],
option: true,
other: 5
---
(source
2021-09-01 14:59:04 +00:00
(call
(identifier)
(arguments
(list
(integer)
(integer))
(keywords
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(boolean))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(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)
=====================================
2021-09-25 00:23:37 +00:00
outer_fun inner_fun a, b
outer_fun inner_fun do: 1
2021-09-01 14:59:04 +00:00
---
(source
(call
(identifier)
(arguments
(call
(identifier)
(arguments
2021-09-25 00:23:37 +00:00
(identifier)
(identifier)))))
(call
(identifier)
(arguments
(call
(identifier)
(arguments
(keywords
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-25 00:23:37 +00:00
(integer))))))))
2021-09-01 14:59:04 +00:00
=====================================
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
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(boolean))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(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
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(boolean))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(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))
2021-09-25 00:23:37 +00:00
(arguments
(binary_operator
(integer)
(call
(dot
(alias)
(identifier))
(arguments
(integer)))))))
2021-09-01 14:59:04 +00:00
=====================================
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)
2021-09-25 00:23:37 +00:00
(string
2021-09-28 14:00:35 +00:00
(quoted_content)))
2021-09-25 00:23:37 +00:00
(arguments
(identifier)))
(call
(dot
(alias)
(charlist
2021-09-28 14:00:35 +00:00
(quoted_content)))
2021-09-01 14:59:04 +00:00
(arguments
(identifier))))
=====================================
remote call / atom literal module
=====================================
:mod.fun(a)
:"Elixir.Mod".fun(a)
---
(source
(call
(dot
2021-09-28 14:00:35 +00:00
(atom)
2021-09-01 14:59:04 +00:00
(identifier))
(arguments
(identifier)))
(call
(dot
2021-09-28 14:00:35 +00:00
(quoted_atom
(quoted_content))
2021-09-01 14:59:04 +00:00
(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
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(boolean))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(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)
2021-09-25 00:23:37 +00:00
(arguments
(call
(dot
(identifier))
(arguments
(identifier))))))))
2021-09-01 14:59:04 +00:00
=====================================
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))
2021-09-25 00:23:37 +00:00
(integer)))
(identifier))))
2021-09-01 14:59:04 +00:00
=====================================
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
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(boolean))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(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)
2021-09-28 14:00:35 +00:00
(atom)))
2021-09-01 14:59:04 +00:00
=====================================
access syntax / does not allow whitespace
=====================================
map [key]
---
(source
(call
(identifier)
(arguments
(list
(identifier)))))
=====================================
2021-09-25 00:23:37 +00:00
access syntax / precedence with dot call
2021-09-01 14:59:04 +00:00
=====================================
2021-09-25 00:23:37 +00:00
map.map[:key]
2021-09-01 14:59:04 +00:00
map[:mod].fun
---
(source
2021-09-25 00:23:37 +00:00
(access_call
(call
(dot
(identifier)
(identifier)))
2021-09-28 14:00:35 +00:00
(atom))
2021-09-01 14:59:04 +00:00
(call
(dot
(access_call
(identifier)
2021-09-28 14:00:35 +00:00
(atom))
2021-09-01 14:59:04 +00:00
(identifier))))
2021-09-25 00:23:37 +00:00
=====================================
access syntax / precedence with operators
=====================================
-x[:key]
@x[:key]
&x[:key]
&1[:key]
---
(source
(unary_operator
(access_call
(identifier)
2021-09-28 14:00:35 +00:00
(atom)))
2021-09-25 00:23:37 +00:00
(access_call
(unary_operator
(identifier))
2021-09-28 14:00:35 +00:00
(atom))
2021-09-25 00:23:37 +00:00
(unary_operator
(access_call
(identifier)
2021-09-28 14:00:35 +00:00
(atom)))
2021-09-25 00:23:37 +00:00
(access_call
(unary_operator
(integer))
2021-09-28 14:00:35 +00:00
(atom)))
2021-09-25 00:23:37 +00:00
=====================================
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)))
2021-09-28 15:26:43 +00:00
=====================================
[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)))
2021-09-01 14:59:04 +00:00
=====================================
[error] leading argument separator
=====================================
fun(, a)
---
(source
(call
(identifier)
(arguments
(ERROR)
(identifier))))
2021-09-25 00:23:37 +00:00
=====================================
[error] trailing argument separator
=====================================
fun(a,)
---
(source
(call
(identifier)
(arguments
(identifier)
(ERROR))))