============================================
Do statements
============================================

do
  local a2 = 2 * a
  local d = sqrt(b ^ 2 - 4 * a * c)
  x1 = (-b + d) / a2
  x2 = (-b - d) / a2
end
print(x1, x2)

---

(program
  (do_statement
    (local_variable_declaration (variable_declarator (identifier))
      (binary_operation (number) (identifier)))
    (local_variable_declaration (variable_declarator (identifier))
      (function_call (identifier)
        (arguments
          (binary_operation
            (binary_operation (identifier) (number))
            (binary_operation
              (binary_operation (number) (identifier))
              (identifier))))))
    (variable_declaration (variable_declarator (identifier))
      (binary_operation
        (binary_operation (unary_operation (identifier))
        (identifier))
      (identifier)))
    (variable_declaration (variable_declarator (identifier))
      (binary_operation
        (binary_operation (unary_operation (identifier))
        (identifier))
      (identifier))))
  (function_call (identifier)
    (arguments (identifier) (identifier))))

============================================
If clauses
============================================

if num > 40 then
  print('over 40')
elseif s ~= 'walternate' then
  io.write('not over 40\n')
else
  thisIsGlobal = 5

  local line = io.read()

  print('Winter is coming, ' .. line)
end

---

(program
  (if_statement
    (condition_expression (binary_operation (identifier) (number)))
      (function_call (identifier)
        (arguments (string)))
    (elseif (condition_expression (binary_operation (identifier) (string)))
      (function_call (field_expression (identifier) (property_identifier))
        (arguments (string))))
    (else
      (variable_declaration (variable_declarator (identifier)) (number))

      (local_variable_declaration (variable_declarator (identifier))
        (function_call (field_expression (identifier) (property_identifier))
          (arguments)))

      (function_call (identifier)
        (arguments (binary_operation (string) (identifier)))))))

============================================
While statements
============================================

while num < 50 do
  num = num + 1
end

---

(program
  (while_statement
    (condition_expression
      (binary_operation (identifier) (number)))
        (variable_declaration (variable_declarator (identifier))
          (binary_operation (identifier) (number)))))

============================================
Repeat statements
============================================

repeat
  print('the way of the future')
  num = num - 1
until num == 0

---

(program
  (repeat_statement
    (function_call (identifier) (arguments (string)))
    (variable_declaration (variable_declarator (identifier))
      (binary_operation (identifier) (number)))
  (condition_expression (binary_operation (identifier) (number)))))

============================================
For statement
============================================

karlSum = 0
for i = 1, 100 do
  karlSum = karlSum + i
end

fredSum = 0
for j = 100, 1, -1 do
  fredSum = fredSum + j
end

v = {'value1', 'value2', 1.21, 'gigawatts'}
for i = 1, #v do
  print(v[i])
end

---

(program
  (variable_declaration (variable_declarator (identifier)) (number))
  (for_statement (loop_expression (identifier) (number) (number))
    (variable_declaration (variable_declarator (identifier))
      (binary_operation (identifier) (identifier))))

  (variable_declaration (variable_declarator (identifier)) (number))
  (for_statement (loop_expression (identifier) (number) (number) (unary_operation (number)))
    (variable_declaration (variable_declarator (identifier))
      (binary_operation (identifier) (identifier))))

  (variable_declaration (variable_declarator (identifier))
    (table (field (string)) (field (string)) (field (number)) (field (string))))
  (for_statement (loop_expression (identifier) (number) (unary_operation (identifier)))
    (function_call (identifier) (arguments (identifier) (identifier)))))

============================================
For in statements
============================================

for key, val in pairs(u) do
  print(key, val)
end

for key, val in ipairs(u) do
  print(key, val)
end

for key, val in next, u do
  print(key, val)
end

---

(program
  (for_in_statement (loop_expression (identifier) (identifier) (function_call (identifier) (arguments (identifier))))
    (function_call (identifier) (arguments (identifier) (identifier))))
    
  (for_in_statement (loop_expression (identifier) (identifier) (function_call (identifier) (arguments (identifier))))
    (function_call (identifier) (arguments (identifier) (identifier))))
  
  (for_in_statement (loop_expression (identifier) (identifier) (next) (identifier))
    (function_call (identifier) (arguments (identifier) (identifier)))))

============================================
Goto statements
============================================

goto someLuaLabel

---

(program
  (goto_statement (identifier)))

============================================
Break statements
============================================

for i = 1, 10 do
  if i == 5 then
    break
  end
end

---

(program
  (for_statement
    (loop_expression (identifier) (number) (number))
      (if_statement
        (condition_expression
          (binary_operation (identifier) (number)))
            (break_statement))))

============================================
Label statements
============================================

:: someLuaLabel ::

---

(program
  (label_statement (identifier)))
