| Crates.io | game_quest_parser_Hodik |
| lib.rs | game_quest_parser_Hodik |
| version | 0.1.2 |
| created_at | 2025-11-19 18:02:30.601173+00 |
| updated_at | 2025-11-20 14:24:36.278392+00 |
| description | A parser for the Game Quest Definition Language (GQDL) |
| homepage | |
| repository | https://github.com/f1orevita/game_quest_parser |
| max_upload_size | |
| id | 1940515 |
| size | 23,764 |
Author Hodik Maksym
Project: Game Quest Parser (Course Project) Goal: To create a parser for a custom domain-specific language (DSL) for RPG games.
Game Quest Parser is a robust command-line tool and library written in Rust for parsing the Game Quest Definition Language (GQDL).
It allows game developers to define RPG quests in a simple, human-readable text format and converts them into structured Rust objects. This project demonstrates the implementation of a Recursive Descent Parser from scratch, ensuring strict type safety and detailed error reporting.
thiserror (library) and anyhow (CLI).clap.The parsing process transforms raw text into a usable data structure through two main stages:
The Lexer scans the source code character by character and groups them into Tokens.
active: true[Token::Identifier("active"), Token::Colon, Token::True]The Parser iterates through the tokens and builds an Abstract Syntax Tree (AST) represented by the Quest struct. It validates the order of tokens against the defined grammar rules.
Data Flow Diagram:
[ Source File ] -> [ Lexer ] -> [ Token Stream ] -> [ Parser ] -> [ Quest Struct ]
|
(Validates Grammar)
Grammar Rules The parser follows the EBNF (Extended Backus-Naur Form) grammar rules below:
EBNF
QUEST_DEF ::= "quest" (IDENTIFIER | STRING) "{" BODY "}"
BODY ::= PROPERTY (","? PROPERTY)*
PROPERTY ::= KEY ":" VALUE
KEY ::= "reward" | "active" | "step"
VALUE ::= INTEGER | BOOLEAN | STRING
Example Input (test_quest.txt)
quest "The Lost Sword" {
active: true,
reward: 500,
step: "Talk to the blacksmith",
step: "Find the cave entrance",
step: "Defeat the skeleton king"
}
Installation & Usage Prerequisites Rust and Cargo (latest stable version) CLI Commands