difftastic/vendored_parsers/tree-sitter-lua/corpus/expressions.txt

91 lines
2.0 KiB
Plaintext

============================================
Tables
============================================
food = {
["favorites"] = {
['pizza'] = true,
hotdog = false
}
}
local games = {
favorites = {
{ 'the witcher', "world of warcraft", 'dragon age', "mass effect" }
}
}
---
(program
(variable_declaration (variable_declarator (identifier))
(table
(field (string)
(table
(field (string) (true))
(field (identifier) (false))))))
(local_variable_declaration (variable_declarator (identifier))
(table
(field (identifier)
(table
(field
(table
(field (string))
(field (string))
(field (string))
(field (string)))))))))
============================================
Binary operations
============================================
a = i + j * 3 - j % 5
b = k + v % 5 ^ 2
c = i * 2 ^ j
---
(program
(variable_declaration (variable_declarator (identifier))
(binary_operation
(binary_operation (identifier)
(binary_operation (identifier) (number)))
(binary_operation (identifier) (number))))
(variable_declaration (variable_declarator (identifier))
(binary_operation (identifier)
(binary_operation (identifier)
(binary_operation (number) (number)))))
(variable_declaration (variable_declarator (identifier))
(binary_operation (identifier)
(binary_operation (number) (identifier)))))
============================================
Unary operations
============================================
food_table_size = #food
negative_value = -value
tern_bool = not condition and true or false
---
(program
(variable_declaration (variable_declarator (identifier))
(unary_operation (identifier)))
(variable_declaration (variable_declarator (identifier))
(unary_operation (identifier)))
(variable_declaration (variable_declarator (identifier))
(binary_operation
(binary_operation
(unary_operation (identifier)) (true))
(false))))