tree-sitter-bp/test/corpus/expressions.txt

400 lines
9.3 KiB
Plaintext
Raw Permalink Normal View History

2024-04-08 00:39:47 +02:00
================================================================================
Boolean
================================================================================
foo = false
foo = true
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:39:47 +02:00
(boolean_literal))
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:39:47 +02:00
(boolean_literal)))
================================================================================
Boolean (identifier/literal)
================================================================================
true = false
false = true
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:39:47 +02:00
(boolean_literal))
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:39:47 +02:00
(boolean_literal)))
2024-04-07 23:49:15 +02:00
================================================================================
Integer
================================================================================
foo = 0
foo = 42
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-07 23:49:15 +02:00
(integer_literal))
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-07 23:49:15 +02:00
(integer_literal)))
================================================================================
Integer (negative)
================================================================================
foo = -0
foo = -42
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-07 23:49:15 +02:00
(integer_literal))
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-07 23:49:15 +02:00
(integer_literal)))
================================================================================
String
================================================================================
foo = "Hello World!"
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
(interpreted_string_literal)))
================================================================================
String (escape)
================================================================================
foo = "Hello\nWorld!"
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
(interpreted_string_literal
(escape_sequence))))
================================================================================
String (raw)
================================================================================
foo = `Hello\nWorld!`
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
(raw_string_literal)))
2024-04-08 00:24:14 +02:00
================================================================================
List (empty)
================================================================================
foo = []
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:24:14 +02:00
(list_expression)))
================================================================================
List (singleton)
================================================================================
foo = [42]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:24:14 +02:00
(list_expression
(integer_literal))))
================================================================================
List (singleton multiline)
================================================================================
foo = [
42
]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:24:14 +02:00
(list_expression
(integer_literal))))
================================================================================
List (singleton trailing comma)
================================================================================
foo = [
42,
]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:24:14 +02:00
(list_expression
(integer_literal))))
================================================================================
List (mixed values)
================================================================================
foo = [
42,
"foobar",
]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:24:14 +02:00
(list_expression
(integer_literal)
(interpreted_string_literal))))
================================================================================
List (list of list)
================================================================================
foo = [
[42],
["foobar"],
[],
]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:24:14 +02:00
(list_expression
(list_expression
(integer_literal))
(list_expression
(interpreted_string_literal))
(list_expression))))
================================================================================
List (rogue comma)
================================================================================
foo = [
,
]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:24:14 +02:00
(list_expression
(ERROR))))
2024-04-08 00:36:21 +02:00
================================================================================
Map (empty)
================================================================================
foo = {}
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:36:21 +02:00
(map_expression)))
================================================================================
Map (singleton)
================================================================================
foo = {foo:42}
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:36:21 +02:00
(map_expression
(property
(identifier)
(integer_literal)))))
2024-04-08 00:36:21 +02:00
================================================================================
Map (singleton multiline)
================================================================================
foo = {
foo: 42
}
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:36:21 +02:00
(map_expression
(property
(identifier)
(integer_literal)))))
2024-04-08 00:36:21 +02:00
================================================================================
Map (singleton trailing comma)
================================================================================
foo = {
foo: 42,
}
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:36:21 +02:00
(map_expression
(property
(identifier)
(integer_literal)))))
2024-04-08 00:36:21 +02:00
================================================================================
Map (mixed values)
================================================================================
foo = {
answer: 42,
value: "foobar",
}
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:36:21 +02:00
(map_expression
(property
(identifier)
(integer_literal))
(property
(identifier)
(interpreted_string_literal)))))
2024-04-08 00:36:21 +02:00
================================================================================
Map (map of map)
================================================================================
foo = {
the: {answer: 42},
}
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:36:21 +02:00
(map_expression
(property
2024-04-08 00:36:21 +02:00
(identifier)
(map_expression
(property
(identifier)
(integer_literal)))))))
2024-04-08 00:36:21 +02:00
================================================================================
Map (rogue comma)
================================================================================
foo = {
,
}
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 00:36:21 +02:00
(map_expression
(ERROR))))
2024-04-08 03:12:22 +02:00
================================================================================
Binary operators
================================================================================
foo = [
-12 + -27 + 42,
"a" + "b",
]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 03:12:22 +02:00
(list_expression
(binary_expression
(binary_expression
(integer_literal)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 03:12:22 +02:00
(integer_literal))
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 03:12:22 +02:00
(integer_literal))
(binary_expression
(interpreted_string_literal)
2024-04-08 03:13:43 +02:00
(operator)
2024-04-08 03:12:22 +02:00
(interpreted_string_literal)))))