Expand description
§Command Parser
This module defines the core functionality for parsing RPG-style chat commands. It uses the Pest parser library for grammar-based parsing.
§Grammar
The grammar is defined in the grammar.pest file and supports the following:
- Verbs: The primary action of the command (e.g., /cast, /attack).
- Targets: Optional targets for the action (e.g., /cast fireball).
- Flags: Key-value pairs for additional parameters (e.g., –power=high).
§Example
use rpg_chat_command_parser::parse_command;
let input = “/cast fireball –power=high”; let parsed = parse_command(input).unwrap(); assert_eq!(parsed.verb, “cast”); assert_eq!(parsed.target, Some(“fireball”.to_string())); assert_eq!(parsed.flags.get(“power”), Some(&“high”.to_string()));
Structs§
- Parsed
Command - Represents a parsed command with its components.
Enums§
Functions§
- parse_
command - Parses an input string into a ParsedCommand.