tree-sitter-tiger/test/corpus/arithmetic.txt

212 lines
6.2 KiB
Plaintext
Raw Normal View History

2022-06-01 19:34:31 +02:00
================================================================================
Multiplication / division
================================================================================
12 * 27 / 42
--------------------------------------------------------------------------------
(source_file
(binary_expression
left: (binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal))
operator: (operator)
right: (integer_literal)))
================================================================================
Addition / substraction
================================================================================
12 + 27 - 42
--------------------------------------------------------------------------------
(source_file
(binary_expression
left: (binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal))
operator: (operator)
right: (integer_literal)))
================================================================================
Comparisons
================================================================================
12 <= 27
--------------------------------------------------------------------------------
(source_file
(binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal)))
================================================================================
Non-associative comparisons
================================================================================
12 <= 27 <= 42
--------------------------------------------------------------------------------
(source_file
(binary_expression
left: (binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal))
operator: (operator)
right: (integer_literal)))
================================================================================
And
================================================================================
12 & 27 & 42
--------------------------------------------------------------------------------
(source_file
(binary_expression
left: (binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal))
operator: (operator)
right: (integer_literal)))
================================================================================
Or
================================================================================
12 | 27 | 42
--------------------------------------------------------------------------------
(source_file
(binary_expression
left: (binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal))
operator: (operator)
right: (integer_literal)))
================================================================================
Unary minus
================================================================================
- - 12
--------------------------------------------------------------------------------
(source_file
(unary_expression
operator: (operator)
expression: (unary_expression
operator: (operator)
expression: (integer_literal))))
================================================================================
Precedence
================================================================================
-1 | 2 & 3 <= 4 + 5 * 6
--------------------------------------------------------------------------------
(source_file
(unary_expression
operator: (operator)
expression: (binary_expression
left: (integer_literal)
operator: (operator)
right: (binary_expression
left: (integer_literal)
operator: (operator)
right: (binary_expression
left: (integer_literal)
operator: (operator)
right: (binary_expression
left: (integer_literal)
operator: (operator)
right: (binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal))))))))
2022-06-02 09:42:12 +02:00
================================================================================
Parenthesis precedence
================================================================================
-(((((1 | 2) & 3) <= 4) + 5) * 6)
--------------------------------------------------------------------------------
(source_file
(unary_expression
operator: (operator)
expression: (sequence_expression
(binary_expression
left: (sequence_expression
(binary_expression
left: (sequence_expression
(binary_expression
left: (sequence_expression
(binary_expression
left: (sequence_expression
(binary_expression
left: (integer_literal)
operator: (operator)
right: (integer_literal)))
operator: (operator)
right: (integer_literal)))
operator: (operator)
right: (integer_literal)))
operator: (operator)
right: (integer_literal)))
operator: (operator)
right: (integer_literal)))))
================================================================================
Sequence
================================================================================
(12; "27"; nil)
--------------------------------------------------------------------------------
(source_file
(sequence_expression
(integer_literal)
(string_literal)
(nil_literal)))
================================================================================
Simple parenthesized expression
================================================================================
(42)
--------------------------------------------------------------------------------
(source_file
(sequence_expression
(integer_literal)))
================================================================================
Empty sequence
================================================================================
()
--------------------------------------------------------------------------------
(source_file
(sequence_expression))