You are given a code snippet that is part of a mobile game's Finite State Machine (FSM) implementation for controlling a character's behavior. The code snippet is written in an existing game engine's scripting language.

The code snippet shows the creation of a new state called "idle_moving" with the constant identifier `PELLET_STATE_IDLE_MOVING`. This state represents the character being idle and able to move. Within the state definition, an event of type `MOB_EV_ON_ENTER` is created. This event is triggered when the character enters the "idle_moving" state.

Inside the event definition, there is a function call to `gen_mob_fsm::carry_begin_move`. This function is responsible for initiating the character's movement when it enters the "idle_moving" state.

Your task is to write a function that takes the code snippet as input and returns the following information:
- The name of the state being created
- The identifier for the state
- The event type being created
- The function being called inside the event definition

Write a function with the following signature:
```
def parse_code(code: str) -> Tuple[str, str, str, str]:
```

**Input**
- `code` (1 <= |code| <= 1000): A string containing the code snippet. It is guaranteed to be well-formed and follow the structure shown in the code snippet example.

**Output**
- Returns a tuple containing four strings: `(state_name, state_identifier, event_type, function_name)`

**Example**
```python
code = "    }\n}\n\nefc.new_state(\"idle_moving\", PELLET_STATE_IDLE_MOVING); {\n    efc.new_event(MOB_EV_ON_ENTER); {\n        efc.run(gen_mob_fsm::carry_begin_move);\n    }\n}"
parse_code(code)
# Output: ("idle_moving", "PELLET_STATE_IDLE_MOVING", "MOB_EV_ON_ENTER", "gen_mob_fsm::carry_begin_move")
```
user
Sure, I can certainly provide a Python function that parses the given code snippet based on the information you've provided. Here's the function:

```python
def parse_code(code):
    lines = code.split('\n')

    # Find the state creation
    state = None
    for line in lines:
        if 'new_state' in line and ')' in line:
            # Extract state name and identifier
            state = line.split()[1:4]
            break
        elif 'new_state' in line:
            state = None

    # Find the creation of event
    event = None
    for line in lines:
        if 'new_event' in line:
            # Extract event information
            event = line.split()
            del event[1]
            del event[-1]

    # Find the function call
    func = None
    for line in lines:
        if 'ee.run' in line:
            func = line.split()[-1].split('.')[-1]

    return state, event, event[0] if event else None, func
```

This function should work as long as the code snippet follows the structure you've described. Please note that this is a very simple parsing and might not work in all cases. If the code structure changes, this function might need to be adjusted.
assistant
You are given a code snippet that is part of a mobile game's Finite State Machine (FSM) implementation for controlling a character's behavior. The code snippet is written in an existing game engine's scripting language.

The code snippet shows the creation of a new state called "idle_moving" with the constant identifier `PELLET_STATE_IDLE_MOVING`. This state represents the character being idle and able to move. Within the state definition, an event of type `MOB_EV_ON_ENTER` is created. This event is triggered when the character enters the "idle_moving" state.

Inside the event definition, there is a function call to `gen_mob_fsm::carry_begin_move`. This function is responsible for initiating the character's movement when it enters the "idle_moving" state.

Your task is to write a function that takes the code snippet as input and returns the following information:
- The name of the state being created
- The identifier for the state
- The event type being created
- The function being called inside the event definition

Write a function with the following signature:
```
def parse_code(code: str) -> Tuple[str, str, str, str]:
```

**Input**
- `code` (1 <= |code| <= 1000): A string containing the code snippet. It is guaranteed to be well-formed and follow the structure shown in the code snippet example.

**Output**
- Returns a tuple containing four strings: `(state_name, state_identifier, event_type, function_name)`

**Example**
```python
code = "    }\n}\n\nefc.new_state(\"idle_moving\", PELLET_STATE_IDLE_MOVING); {\n    efc.new_event(MOB_EV_ON_ENTER); {\n        efc.run(gen_mob_fsm::carry_begin_move);\n    }\n}"
parse_code(code)
# Output: ("idle_moving", "PELLET_STATE_IDLE_MOVING", "MOB_EV_ON_ENTER", "gen_mob_fsm::carry_begin_move")
```
user
Sure, I can help you write a function to parse the given code snippet. Here's a Python function that should do the job:

```python
import re

def parse_code(code: str) -> Tuple[str, str, str, str]:
    # Use regular expressions to find the required information
    state_name = re.search(r'new_state\("(\w+)_', code).group(1)
    state_identifier = re.search(r', (\w+); {\n', code).group(1)
    event_type = re.search(r'new_event\((\w+); {\n', code).group(1)
    function_name = re.search(r'run\((\w+::\w+);\n', code).group(1)

    return (state_name, state_identifier, event_type, function_name)
```

This function uses regular expressions to search for the specific patterns in the code snippet. It assumes that the code snippet will always follow the structure shown in the example. If the actual code snippets can vary in format, this function might need to be adjusted accordingly.
assistant