
================================================================================
Commands
================================================================================

echo "hello"

set hi "heelo"

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

(source_file
  (command
    (simple_word)
    (word_list
      (quoted_word)))
  (set
    (simple_word)
    (quoted_word)))

================================================================================
Procedures
================================================================================

proc foo {arg1 arg2} {
    echo "hello"
    echo "word$hi \$bye word"
}

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

(source_file
  (procedure
    (simple_word)
    (arguments
      (argument
        (simple_word))
      (argument
        (simple_word)))
    (braced_word
      (command
        (simple_word)
        (word_list
          (quoted_word)))
      (command
        (simple_word)
        (word_list
          (quoted_word
            (variable_substitution
              (id))
            (escaped_character)))))))

================================================================================
Comments
================================================================================

# this is a comment

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

(source_file
  (comment))

================================================================================
Foreach
================================================================================

foreach a {1 2 3 4 5} {
    put $i
}

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

(source_file
  (foreach
    (arguments
      (simple_word))
    (braced_word_simple
      (simple_word)
      (simple_word)
      (simple_word)
      (simple_word)
      (simple_word))
    (braced_word
      (command
        (simple_word)
        (word_list
          (variable_substitution
            (id)))))))

================================================================================
Conditionals
================================================================================

if hello {
    echo hi
} elseif hello {
    echo hi
} else {
    echo bye
}

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

(source_file
  (conditional
    (expr
      (simple_word))
    (braced_word
      (command
        (simple_word)
        (word_list
          (simple_word))))
    (elseif
      (expr
        (simple_word))
      (braced_word
        (command
          (simple_word)
          (word_list
            (simple_word)))))
    (else
      (braced_word
        (command
          (simple_word)
          (word_list
            (simple_word)))))))

================================================================================
Command substitution
================================================================================

echo [echo hello]

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

(source_file
  (command
    (simple_word)
    (word_list
      (command_substitution
        (command
          (simple_word)
          (word_list
            (simple_word)))))))

================================================================================
Escaped string
================================================================================

echo "word$hi \$bye word"

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

(source_file
  (command
    (simple_word)
    (word_list
      (quoted_word
        (variable_substitution
          (id))
        (escaped_character)))))
