| Crates.io | roguemap |
| lib.rs | roguemap |
| version | 0.1.0 |
| created_at | 2025-11-25 11:21:53.276707+00 |
| updated_at | 2025-11-25 11:21:53.276707+00 |
| description | Parser and renderer for procedural dungeon map generation in roguelike games |
| homepage | https://github.com/femedron/rogue_map |
| repository | https://github.com/femedron/rogue_map |
| max_upload_size | |
| id | 1949587 |
| size | 48,091 |
A domain-specific language (DSL) parser and renderer for procedural dungeon map generation in roguelike games.
RogueMap is a specialized parser that reads declarative dungeon definitions and transforms them into visual ASCII representations. It allows game developers to define rooms, corridors, connections, and metadata tags in a human-readable format that can be easily parsed, validated, and rendered.
cargo install roguemap
# Render dungeon map
roguemap -i dungeon.rmap
# Save output to file
roguemap -i dungeon.rmap -o output.txt
# Display Abstract Syntax Tree
roguemap -i dungeon.rmap --ast
# Show credits
roguemap --credits
example.rmap)# Starting area of the dungeon
tag biome = "underground"
tag difficulty = hard
room start 10x8 at (2, 3) {
name = "Entrance"
loot = [gold:10]
monster = none
}
room hall 20x4 at (2, 15) {
name = "Main Hall"
loot = [potion:2, scroll:1]
}
corridor 6 from start to hall
connect hall to start via west
room boss 12x12 at (20, 20) {
name = "Boss Room"
loot = [gold:100, potion:5, relic:1]
monster = dragon
}
connect hall to boss via south
############
#..........#
#..........#
#..........#
#..........#
#boss......#
#..........#
#..........#
#..........#
#..........#
#LM........#
############
####################
#hall..............#
#L........+........#
##########+#########
+
+
+
+
##########+
#........#+
#........#+
#star++++++
#........#
#........#
#LM......#
##########
The input text is tokenized according to grammar rules. The lexer identifies:
room, corridor, connect, tag, via, from, to, at10, 8) and strings ("Entrance")=, :, and delimiters {, }, [, ], (, )# (ignored)The parser constructs a hierarchical parse tree based on grammar rules:
dungeon
└── statement*
├── tag_decl: tag biome = "underground"
├── tag_decl: tag difficulty = hard
├── room_decl: room start 10x8 at (2, 3) { ... }
├── room_decl: room hall 20x4 at (2, 15) { ... }
├── corridor_decl: corridor 6 from start to hall
├── connect_decl: connect hall to start via west
└── ...
Each statement type has specific sub-rules that must be satisfied for valid syntax.
The parse tree is transformed into strongly-typed Rust structs:
Dungeon {
statements: Vec<Statement>
}
Statement = Room | Corridor | Connection | Tag
Room {
name: String,
width: usize,
height: usize,
x: usize,
y: usize,
props: Vec<RoomProp>
}
RoomProp = Name(String) | Loot(Vec<LootItem>) | Monster(String)
This ensures type safety and enables pattern matching during processing.
During AST construction, the parser validates:
The validated AST is used for:
Author: Maksym Stetsyk | Year: 2025
Repository: github.com/femedron/rogue_map