==================
Simple Behavior
==================

behavior SimpleBehavior {
    walk_around
}

---

(source_file
  (declaration
    (behavior
      name: (identifier)
      root: (behavior_node
        (action_node (identifier))))))

==================
Selector Behavior
==================

behavior SelectorBehavior {
    ? {
        try_option_a
        try_option_b
        fallback
    }
}

---

(source_file
  (declaration
    (behavior
      name: (identifier)
      root: (behavior_node
        (selector_node
          (behavior_node (action_node (identifier)))
          (behavior_node (action_node (identifier)))
          (behavior_node (action_node (identifier))))))))

==================
Sequence Behavior
==================

behavior SequenceBehavior {
    > {
        check_energy
        move_to_location
        perform_action
    }
}

---

(source_file
  (declaration
    (behavior
      name: (identifier)
      root: (behavior_node
        (sequence_node
          (behavior_node (action_node (identifier)))
          (behavior_node (action_node (identifier)))
          (behavior_node (action_node (identifier))))))))

==================
Nested Behavior
==================

behavior NestedBehavior {
    > {
        ? {
            check_condition_a
            check_condition_b
        }
        perform_action
    }
}

---

(source_file
  (declaration
    (behavior
      name: (identifier)
      root: (behavior_node
        (sequence_node
          (behavior_node
            (selector_node
              (behavior_node (action_node (identifier)))
              (behavior_node (action_node (identifier)))))
          (behavior_node (action_node (identifier))))))))

==================
Repeat Behavior
==================

behavior RepeatBehavior {
    * {
        patrol
    }
}

---

(source_file
  (declaration
    (behavior
      name: (identifier)
      root: (behavior_node
        (repeat_node
          (behavior_node (action_node (identifier))))))))

==================
Behavior with Subtree
==================

behavior WithSubtree {
    > {
        @helpers::check_preconditions
        main_action
    }
}

---

(source_file
  (declaration
    (behavior
      name: (identifier)
      root: (behavior_node
        (sequence_node
          (behavior_node
            (subtree_node
              (path
                (path_segments
                  (identifier)
                  (identifier)))))
          (behavior_node (action_node (identifier))))))))

==================
Complex Nested Behavior
==================

behavior ComplexBehavior {
    ? {
        > {
            check_threat
            flee_to_safety
        }
        > {
            check_resources
            gather_resources
        }
        * {
            idle
        }
    }
}

---

(source_file
  (declaration
    (behavior
      name: (identifier)
      root: (behavior_node
        (selector_node
          (behavior_node
            (sequence_node
              (behavior_node (action_node (identifier)))
              (behavior_node (action_node (identifier)))))
          (behavior_node
            (sequence_node
              (behavior_node (action_node (identifier)))
              (behavior_node (action_node (identifier)))))
          (behavior_node
            (repeat_node
              (behavior_node (action_node (identifier))))))))))

