================================================================================
Multiplication expression
================================================================================

45 * 3

--------------------------------------------------------------------------------

(source_file
  (multiplicative_expression
    (integer_literal)
    (integer_literal)))

================================================================================
Safe Navigation
================================================================================

a?.bar()
a? .bar()
a? . bar()
a?
  .bar()
a ? . bar()

--------------------------------------------------------------------------------

(source_file
  (call_expression
    (navigation_expression
      (simple_identifier)
      (navigation_suffix
        (simple_identifier)))
    (call_suffix
      (value_arguments)))
  (call_expression
    (navigation_expression
      (simple_identifier)
      (navigation_suffix
        (simple_identifier)))
    (call_suffix
      (value_arguments)))
  (call_expression
    (navigation_expression
      (simple_identifier)
      (navigation_suffix
        (simple_identifier)))
    (call_suffix
      (value_arguments)))
  (call_expression
    (navigation_expression
      (simple_identifier)
      (navigation_suffix
        (simple_identifier)))
    (call_suffix
      (value_arguments)))
  (call_expression
    (navigation_expression
      (simple_identifier)
      (navigation_suffix
        (simple_identifier)))
    (call_suffix
      (value_arguments))))

================================================================================
Function calls
================================================================================

print("Hello World!")
sum(1, 2)

--------------------------------------------------------------------------------

(source_file
  (call_expression
    (simple_identifier)
    (call_suffix
      (value_arguments
        (value_argument
          (string_literal
            (string_content))))))
  (call_expression
    (simple_identifier)
    (call_suffix
      (value_arguments
        (value_argument
          (integer_literal))
        (value_argument
          (integer_literal))))))

================================================================================
When expression
================================================================================

val x = 1
val y = when(x){
        1 -> true
        2 -> false
    }

--------------------------------------------------------------------------------

(source_file
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (integer_literal))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (when_expression
      (when_subject
        (simple_identifier))
      (when_entry
        (when_condition
          (integer_literal))
        (control_structure_body
          (boolean_literal)))
      (when_entry
        (when_condition
          (integer_literal))
        (control_structure_body
          (boolean_literal))))))

================================================================================
When expression with type arguments
================================================================================

when (this) {
    is DispatchedCoroutine<*> -> return null
}

--------------------------------------------------------------------------------

(source_file
  (when_expression
    (when_subject
      (this_expression))
    (when_entry
      (when_condition
        (type_test
          (user_type
            (type_identifier)
            (type_arguments
              (type_projection)))))
      (control_structure_body
        (jump_expression
          (null_literal))))))

================================================================================
Value declaration with receiver type
================================================================================

val MyDate.s: String get() = "hello"

--------------------------------------------------------------------------------

(source_file
  (property_declaration
    (binding_pattern_kind)
    (receiver_type
      (user_type
        (type_identifier)))
    (variable_declaration
      (simple_identifier)
      (user_type
        (type_identifier)))
    (getter
      (function_body
        (string_literal
          (string_content))))))

================================================================================
Expect as an expression
================================================================================

val x = expect(1)

--------------------------------------------------------------------------------

(source_file
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (call_expression
      (simple_identifier)
      (call_suffix
        (value_arguments
          (value_argument
            (integer_literal)))))))

================================================================================
Expect as a top-level expression
================================================================================

expect(1)

--------------------------------------------------------------------------------

(source_file
  (call_expression
    (simple_identifier)
    (call_suffix
      (value_arguments
        (value_argument
          (integer_literal))))))

================================================================================
Expect as a platform modifier
================================================================================

expect fun randomUUID(): String

--------------------------------------------------------------------------------

(source_file
  (function_declaration
    (modifiers
      (platform_modifier))
    (simple_identifier)
    (function_value_parameters)
    (user_type
      (type_identifier))))

================================================================================
Less than for generics
================================================================================

foo<Int>(1,2)
foo<Int>(1)

--------------------------------------------------------------------------------

(source_file
  (call_expression
    (simple_identifier)
    (call_suffix
      (type_arguments
        (type_projection
          (user_type
            (type_identifier))))
      (value_arguments
        (value_argument
          (integer_literal))
        (value_argument
          (integer_literal)))))
  (call_expression
    (simple_identifier)
    (call_suffix
      (type_arguments
        (type_projection
          (user_type
            (type_identifier))))
      (value_arguments
        (value_argument
          (integer_literal))))))

================================================================================
Less than for comparison
================================================================================

val x = a<b
val y = a>b
val z = a<b>c
// this is parsed as a generic, but could also be parsed as a comparison
val w = a<b>(c)
val a = a<2>(3)

--------------------------------------------------------------------------------

(source_file
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (comparison_expression
      (simple_identifier)
      (simple_identifier)))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (comparison_expression
      (simple_identifier)
      (simple_identifier)))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (comparison_expression
      (comparison_expression
        (simple_identifier)
        (simple_identifier))
      (simple_identifier)))
  (line_comment)
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (call_expression
      (simple_identifier)
      (call_suffix
        (type_arguments
          (type_projection
            (user_type
              (type_identifier))))
        (value_arguments
          (value_argument
            (simple_identifier))))))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (comparison_expression
      (comparison_expression
        (simple_identifier)
        (integer_literal))
      (parenthesized_expression
        (integer_literal)))))

================================================================================
Lambda Expressions
================================================================================

foo.forEach { (index, value) -> 2 }

--------------------------------------------------------------------------------

(source_file
  (call_expression
    (navigation_expression
      (simple_identifier)
      (navigation_suffix
        (simple_identifier)))
    (call_suffix
      (annotated_lambda
        (lambda_literal
          (lambda_parameters
            (multi_variable_declaration
              (variable_declaration
                (simple_identifier))
              (variable_declaration
                (simple_identifier))))
          (statements
            (integer_literal)))))))

================================================================================
Function call with trailing lambda
================================================================================

with(s) { length }

--------------------------------------------------------------------------------

(source_file
  (call_expression
    (simple_identifier)
    (call_suffix
      (value_arguments
        (value_argument
          (simple_identifier)))
      (annotated_lambda
        (lambda_literal
          (statements
            (simple_identifier)))))))

================================================================================
Multiple Statements on a Single Line
================================================================================

fun main() { val temp = b.y; b.y = b.z; b.z = temp }

when (dir) {
  1 -> { val temp = b.y; b.y = b.z; b.z = temp }
}
--------------------------------------------------------------------------------

(source_file
  (function_declaration
    (simple_identifier)
    (function_value_parameters)
    (function_body
      (statements
        (property_declaration
          (binding_pattern_kind)
          (variable_declaration
            (simple_identifier))
          (navigation_expression
            (simple_identifier)
            (navigation_suffix
              (simple_identifier))))
        (assignment
          (directly_assignable_expression
            (simple_identifier)
            (navigation_suffix
              (simple_identifier)))
          (navigation_expression
            (simple_identifier)
            (navigation_suffix
              (simple_identifier))))
        (assignment
          (directly_assignable_expression
            (simple_identifier)
            (navigation_suffix
              (simple_identifier)))
          (simple_identifier)))))
  (when_expression
    (when_subject
      (simple_identifier))
    (when_entry
      (when_condition
        (integer_literal))
      (control_structure_body
        (statements
          (property_declaration
            (binding_pattern_kind)
            (variable_declaration
              (simple_identifier))
            (navigation_expression
              (simple_identifier)
              (navigation_suffix
                (simple_identifier))))
          (assignment
            (directly_assignable_expression
              (simple_identifier)
              (navigation_suffix
                (simple_identifier)))
            (navigation_expression
              (simple_identifier)
              (navigation_suffix
                (simple_identifier))))
          (assignment
            (directly_assignable_expression
              (simple_identifier)
              (navigation_suffix
                (simple_identifier)))
            (simple_identifier)))))))

================================================================================
Comments in Strings
================================================================================

val comments = foo("//")
val comments = foo("hello //")
val comments = foo("// there")
val comments = foo("hello // there")
val comments = """ 
  // hey there's a
  
  /* comment or two here */
"""
val comments = """ // and here """ 

--------------------------------------------------------------------------------

(source_file
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (call_expression
      (simple_identifier)
      (call_suffix
        (value_arguments
          (value_argument
            (string_literal
              (string_content)))))))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (call_expression
      (simple_identifier)
      (call_suffix
        (value_arguments
          (value_argument
            (string_literal
              (string_content)))))))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (call_expression
      (simple_identifier)
      (call_suffix
        (value_arguments
          (value_argument
            (string_literal
              (string_content)))))))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (call_expression
      (simple_identifier)
      (call_suffix
        (value_arguments
          (value_argument
            (string_literal
              (string_content)))))))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (string_literal
      (string_content)))
  (property_declaration
    (binding_pattern_kind)
    (variable_declaration
      (simple_identifier))
    (string_literal
      (string_content))))

================================================================================
Qualified this/super expressions
================================================================================

class Square() : Rectangle(), Polygon {
    override fun draw() {
        this@Square.draw()
        super@Square.draw()
        super<Polygon>.draw()
        super<Rectangle>@Square.draw()
    }
}

--------------------------------------------------------------------------------

(source_file
  (class_declaration
    (type_identifier)
    (primary_constructor)
    (delegation_specifier
      (constructor_invocation
        (user_type
          (type_identifier))
        (value_arguments)))
    (delegation_specifier
      (user_type
        (type_identifier)))
    (class_body
      (function_declaration
        (modifiers
          (member_modifier))
        (simple_identifier)
        (function_value_parameters)
        (function_body
          (statements
            (call_expression
              (navigation_expression
                (this_expression
                  (type_identifier))
                (navigation_suffix
                  (simple_identifier)))
              (call_suffix
                (value_arguments)))
            (call_expression
              (navigation_expression
                (super_expression
                  (type_identifier))
                (navigation_suffix
                  (simple_identifier)))
              (call_suffix
                (value_arguments)))
            (call_expression
              (navigation_expression
                (super_expression
                  (user_type
                    (type_identifier)))
                (navigation_suffix
                  (simple_identifier)))
              (call_suffix
                (value_arguments)))
            (call_expression
              (navigation_expression
                (super_expression
                  (user_type
                    (type_identifier))
                  (type_identifier))
                (navigation_suffix
                  (simple_identifier)))
              (call_suffix
                (value_arguments)))))))))

================================================================================
If else-if else expression
================================================================================

if (cond1) {
	println("cond1")
} else if (cond2) {
	println("cond2")
} else {
	println("cond3")
}

--------------------------------------------------------------------------------

(source_file
  (if_expression
    condition: (simple_identifier)
    consequence: (control_structure_body
      (statements
        (call_expression
          (simple_identifier)
          (call_suffix
            (value_arguments
              (value_argument
                (string_literal
                  (string_content))))))))
    alternative: (control_structure_body
      (if_expression
        condition: (simple_identifier)
        consequence: (control_structure_body
          (statements
            (call_expression
              (simple_identifier)
              (call_suffix
                (value_arguments
                  (value_argument
                    (string_literal
                      (string_content))))))))
        alternative: (control_structure_body
          (statements
            (call_expression
              (simple_identifier)
              (call_suffix
                (value_arguments
                  (value_argument
                    (string_literal
                      (string_content))))))))))))

================================================================================
If-else without braces or semicolons or newlines
================================================================================

if (true) a else if (true) b else c

---

(source_file
  (if_expression
    (boolean_literal)
    (control_structure_body
      (simple_identifier))
    (control_structure_body
      (if_expression
        (boolean_literal)
        (control_structure_body
          (simple_identifier))
        (control_structure_body
          (simple_identifier))))))

================================================================================
Infix syntax for function application
================================================================================

a mul b

---

(source_file
  (infix_expression
    (simple_identifier)
    (simple_identifier)
    (simple_identifier)))

================================================================================
Infix syntax, edge case 1
================================================================================

a exxx b
a ixxx b

---

(source_file
  (infix_expression
    (simple_identifier)
    (simple_identifier)
    (simple_identifier))
  (infix_expression
    (simple_identifier)
    (simple_identifier)
    (simple_identifier)))

================================================================================
Infix syntax, edge case 2
================================================================================

a else_ b
a import_ b
a imports b

---

(source_file
  (infix_expression
    (simple_identifier)
    (simple_identifier)
    (simple_identifier))
  (infix_expression
    (simple_identifier)
    (simple_identifier)
    (simple_identifier))
  (infix_expression
    (simple_identifier)
    (simple_identifier)
    (simple_identifier)))
