๐ Parsing โ Input File Introduction¶
๐ฉ๏ธ Fly-in Input System¶
The project receives a .txt file describing:
- the drone count
- all available zones
- zone metadata
- all graph connections
- movement constraints
The parser is responsible for:
- reading the file
- validating syntax
- validating rules
- converting raw text into internal objects
๐ฆ Example Input File¶
# Drone count
nb_drones: 5
# Start and end zones
start_hub: hub 0 0 [color=green]
end_hub: goal 10 10 [color=yellow]
# Regular zones
hub: roof1 3 4 [zone=restricted color=red]
hub: roof2 6 2 [zone=normal color=blue]
hub: corridorA 4 3 [zone=priority color=green max_drones=2]
hub: tunnelB 7 4 [zone=normal color=red]
hub: obstacleX 5 5 [zone=blocked color=gray]
# Connections
connection: hub-roof1
connection: hub-corridorA
connection: roof1-roof2
connection: roof2-goal
connection: corridorA-tunnelB [max_link_capacity=2]
connection: tunnelB-goal
๐งพ File Structure¶
The parser reads the file line by line.
Each line may represent:
- drone count
- zone declaration
- connection declaration
- comments
- empty lines
๐ฌ Comments¶
Lines starting with # are comments.
- comments are ignored by the parser
- comments may appear anywhere
- empty lines should also be ignored
Example:
# This is a comment
๐ข Drone Count¶
The first mandatory entry defines:
nb_drones: <number>
Example:
nb_drones: 5
Rules¶
- must exist
- must be a positive integer
- only one definition is allowed
๐ Zone Definitions¶
| Type | Example | Rules |
|---|---|---|
| ๐ข Start Zone | start_hub: hub 0 0 |
- Exactly one start zone must exist - Coordinates are mandatory - Coordinates are always integers |
| ๐ด End Zone | end_hub: goal 10 10 |
- Exactly one end zone must exist - Coordinates are mandatory - Coordinates are always integers |
| ๐ต Regular Zone | hub: roof1 3 4 |
- Zone names must be unique - Coordinates are mandatory - Coordinates are integers |
๐ซ Invalid Zone Names¶
| Invalid | Valid |
|---|---|
my-zone |
my_zone |
my zone |
roof1 |
Rules¶
- zone names cannot contain spaces
- zone names cannot contain dashes (
-)
๐ฆ Optional Metadata¶
Zones may include optional metadata inside:
[ ... ]
Example:
hub: roof1 3 4 [zone=restricted color=red]
Metadata order does not matter.
๐ท๏ธ Zone Metadata¶
| Metadata | Example | Rules |
|---|---|---|
zone=<type> |
zone=restricted |
Allowed values: normal, restricted, priority, blocked |
color=<value> |
color=red |
Optional single-word string |
max_drones=<number> |
max_drones=2 |
Must be a positive integer |
๐ Connection Definitions¶
Connections define graph edges.
Syntax¶
connection: zoneA-zoneB
Example:
connection: roof1-roof2
โ๏ธ Connection Rules¶
Connections are:
- bidirectional
Meaning:
A-B
allows:
- A โ B
- B โ A
๐ซ Invalid Connections¶
Connections are invalid if:
- zones do not exist
- duplicate edges exist
- syntax is malformed
Example duplicates:
A-B
B-A
๐ฆ Connection Metadata¶
Connections may also contain metadata:
[max_link_capacity=N]
Example:
connection: A-B [max_link_capacity=2]
Rules¶
- optional
- positive integer only
โ ๏ธ Parsing Validation¶
The parser should validate:
- duplicated zones
- duplicated connections
- invalid metadata
- invalid zone types
- invalid capacities
- malformed syntax
- missing start/end zones
- invalid coordinates
๐จ Error Handling¶
Any parsing error should:
- stop parsing immediately
- return a clear error message
Ideally including:
- line number
- reason of failure
Example:
Line 12:
Invalid zone type: lava
๐ง Parsing Goal¶
The parsing system should transform the raw .txt file into:
- graph structures
- zone objects
- connection objects
- metadata structures
that will later be used by:
- pathfinding
- simulation
- scheduling
- visualization systems