==================================
while statement
==================================

class WhileDemo {
    void main(String args){
        int count = 1;
        while (count < 11) {
            System.out.println("Count is: " + count);
            count++;
        }
    }
}

---

 (program
  (class_definition
    name: (identifier)
    body: (class_body
      (method_signature
        (function_signature
        (void_type)
        name: (identifier)
        (formal_parameter_list
          (formal_parameter
             (type_identifier)
            name: (identifier)))

            )
            )

        (function_body
        (block
          (local_variable_declaration (initialized_variable_definition
              (type_identifier)
              name: (identifier)
              value: (decimal_integer_literal)))
          (while_statement
            condition: (parenthesized_expression
              (relational_expression
                 (identifier)
                (relational_operator)
                 (decimal_integer_literal)))
            body: (block
                (expression_statement
                    (identifier)
                    (selector
                      (unconditional_assignable_selector (identifier))
                    )
                    (selector
                      (unconditional_assignable_selector (identifier))
                    )
                    (selector
                      (argument_part (arguments
                        (argument (additive_expression
                            (string_literal)
                            (additive_operator)
                            (identifier)
                        ))
                      ))
                    )
                )
              (expression_statement
                (postfix_expression (assignable_expression (identifier)) (postfix_operator (increment_operator)))
              )
            )
          )
        )
      )
    )
  )
)

==================================
try-with-resources statements
==================================


get a {
var a;
    try {
          int data = input.read();
    } on Exception catch (e) {
        a();
    }
}

---

(program

 (getter_signature 
    name: (identifier))
    (function_body
         (block
            (local_variable_declaration (initialized_variable_definition (inferred_type) name: (identifier)))
              (try_statement
                body: (block
                  (local_variable_declaration
                   (initialized_variable_definition
                      (type_identifier)
                      name: (identifier)
                      value: (identifier)
                      value:
                            (selector
                              (unconditional_assignable_selector (identifier))
                            )
                      value:
                      (selector
                            (argument_part
                                (arguments)
                            )
                      )
                   )
                )
              )
               (type_identifier)
              (catch_clause
                (identifier))
                 (block
                    (expression_statement
                        (identifier)
                        (selector
                            (argument_part
                                (arguments)
                            )
                        )
                    )
                 )
              )

        )
    )
)

==================================
return statement
==================================

return x;
return x * y;
return x + 2;
return fire(x);

---

(program
  (return_statement (identifier))
  (return_statement (multiplicative_expression (identifier) (multiplicative_operator) (identifier)))
  (return_statement (additive_expression (identifier) (additive_operator) (decimal_integer_literal)))
  (return_statement (identifier) (selector (argument_part (arguments (argument (identifier)))))))

==================================
annotation
==================================

@SuppressWarnings(value = "unchecked")
@GwtCompatible(emulated = true)
class Duck {

}

---

(program
  (annotation
    (identifier)
        (arguments (argument (assignment_expression (assignable_expression (identifier)) (string_literal))))
    )
  (annotation
    (identifier)
        (arguments (argument (assignment_expression (assignable_expression (identifier)) (true))))
    )
    (class_definition
    (identifier)
    (class_body)
  )
)

==================================
marker annotation
==================================

@Override
class Quack {
  @bar
  void foo() {

  }
}

---

(program
  (marker_annotation (identifier))
    (class_definition
    (identifier)
    (class_body
      (marker_annotation (identifier))
      (method_signature
      (function_signature
        (void_type)
        (identifier)
        (formal_parameter_list)
        ))
        (function_body
        (block))
        )))

==================================
single element annotation
==================================

@Duck(waddle.swim)
@SuppressWarnings("unchecked")
class Quack {

}

---

(program
  (annotation (identifier)
  (arguments (argument (identifier) (selector (unconditional_assignable_selector (identifier)))))
  )
  (annotation (identifier) (arguments (argument (string_literal))))
    (class_definition
    (identifier)
    (class_body)))

==================================
lambda expression
==================================

class LambdaTest {
  void singleton() {
    var b = (Str version) => create;
    var d = (Str a) {
     int destinysChild = 2;
     };
  }
}

---

(program
  (class_definition
    (identifier)
    (class_body
      (method_signature (function_signature
        (void_type)
        (identifier)
        (formal_parameter_list)))
        (function_body
        (block
          (local_variable_declaration
                (initialized_variable_definition (inferred_type) (identifier)
                    (function_expression
                        (formal_parameter_list (formal_parameter (type_identifier) (identifier)))
                        (function_expression_body (identifier))
                     )
            )
          )
          (local_variable_declaration
              (initialized_variable_definition
              (inferred_type) (identifier) (function_expression
                (formal_parameter_list (formal_parameter (type_identifier) (identifier)) )
                (function_expression_body
                (block
                          (local_variable_declaration
                            (initialized_variable_definition
                             (type_identifier)

                               (identifier)
                               (decimal_integer_literal)))
                )))
                )
            ))


      ))))

==================================
switch statement
==================================

class SwitchDemo {
  static void main(String args) {
    int destinysChild = 2;
    String destinysChildString;
    switch (destinysChild) {
        case 1:  destinysChildString = "Beyonce";
                 break;
        case 2:  destinysChildString = "Kelly";
                 break;
        case 3:  destinysChildString = "Michelle";
                 break;
        default: destinysChildString = "Invalid";
                 break;
    }
    System.out.println(destinysChildString);
  }
}

---

(program
  (class_definition
    name: (identifier)
    body: (class_body
      (method_signature (function_signature
        (void_type)
        name: (identifier)
        (formal_parameter_list
          (formal_parameter
            (type_identifier)
            name: (identifier)
          )
        )

            ))
        (function_body (block
          (local_variable_declaration
            (initialized_variable_definition
            (type_identifier)
              name: (identifier)
              value: (decimal_integer_literal)
            )
          )
          (local_variable_declaration
            (initialized_variable_definition
                (type_identifier)
                name: (identifier)
            )
          )
          (switch_statement
            condition: (parenthesized_expression (identifier))
            body: (switch_block
              (switch_label (case_builtin) (decimal_integer_literal))
              (expression_statement (assignment_expression
                left: (assignable_expression (identifier))
                right: (string_literal)))
              (break_statement)
              (switch_label (case_builtin) (decimal_integer_literal))
              (expression_statement (assignment_expression
                left: (assignable_expression (identifier))
                right: (string_literal)))
              (break_statement)
              (switch_label (case_builtin) (decimal_integer_literal))
              (expression_statement (assignment_expression
                left: (assignable_expression (identifier))
                right: (string_literal)))
              (break_statement)
              (switch_label)
              (expression_statement (assignment_expression
                left: (assignable_expression (identifier))
                right: (string_literal)))
              (break_statement)))
          (expression_statement
              (identifier)
              (selector
                (unconditional_assignable_selector (identifier))
              )
              (selector
                (unconditional_assignable_selector (identifier))
              )
              (selector
                (argument_part (arguments (argument (identifier))))
              )
          )
        )
      )
    )
  )
)

==================================
type arguments
==================================

class Box <T> {
  T theObject;
  Box( T arg) { theObject = arg; }
  // more code
}

---

(program
  (class_definition
    (identifier)
      (type_parameters
        (type_parameter
          (type_identifier)))
    (class_body
      (declaration
          (type_identifier)
(initialized_identifier_list (initialized_identifier (identifier)))
)
      (method_signature (constructor_signature
        (identifier)
        (formal_parameter_list
          (formal_parameter
            (type_identifier)
            (identifier)))))
        (function_body
          (block (expression_statement (assignment_expression
            (assignable_expression (identifier))
              (identifier)))))
      (comment))))

==================================
wildcard
==================================

class WildcardDemo {
  List<B> a;
}

---

(program
  (class_definition
    (identifier)
      (class_body
        (declaration

            (type_identifier)
            (type_arguments
              (type_identifier))
          (initialized_identifier_list (initialized_identifier (identifier)))
          ))))

==================================
type arguments with generic types
==================================

class someClass <T> {
  List<T> someMethod() {
     List< T > list = Collections.emptyList<S>();
     emptyList<S, H>(g);
     return list;
  }
  void anotherMethod<T>(S arg) {
     List< S > list = Collections.emptyList<S>();
  }
}

---

(program
  (class_definition
    (identifier)
    (type_parameters
      (type_parameter
        (type_identifier)))
      (class_body
        (method_signature (function_signature
              (type_identifier)
              (type_arguments (type_identifier))
            (identifier)
            (formal_parameter_list)
            ))
            (function_body (block
              (local_variable_declaration
              (initialized_variable_definition
                  (type_identifier)
                  (type_arguments (type_identifier))
                  (identifier)
                    (identifier)
                    (selector
                      (unconditional_assignable_selector (identifier))
                    )
                    (selector
                        (argument_part
                            (type_arguments
                                (type_identifier)
                            )
                            (arguments)
                        )
                    )
                  )
              )
              (expression_statement
                    (identifier)
                    (selector
                        (argument_part
                            (type_arguments
                                (type_identifier)
                                (type_identifier)
                            )
                            (arguments (argument (identifier)))
                        )
                    )
              )
              (return_statement (identifier))))
        (method_signature (function_signature
                  (void_type)
                    (identifier)
          (type_parameters
            (type_parameter
              (type_identifier)))
            (formal_parameter_list
              (formal_parameter
                (type_identifier)
                (identifier)))
            ))
            (function_body (block
              (local_variable_declaration
                (initialized_variable_definition
                    (type_identifier)
                    (type_arguments (type_identifier))
                    (identifier)
                    (identifier)
                    (selector
                      (unconditional_assignable_selector
                          (identifier)
                      )
                    )
                    (selector
                        (argument_part
                            (type_arguments
                                (type_identifier)
                            ) (arguments)
                        )
                    )
                )
              )
            )
          )
        )
      )
    )


==================================
empty type arguments
==================================

Box<Integer> integerBox = new Box<>();

---

(program
  (type_identifier) (type_arguments (type_identifier)) 
  (initialized_identifier_list 
    (initialized_identifier (identifier) 
      (new_expression (type_identifier) (type_arguments) (arguments)))))

