#nom #parser #half-life #quake #file-format #gamedev

nomap

A parser for the .map file format used by Quake 1 & 2 as well as Half-Life 1, implemented using the nom parsing framework

4 releases

0.2.1 Jun 29, 2021
0.2.0 Aug 19, 2020
0.1.1 Apr 7, 2020
0.1.0 Apr 6, 2020

#1534 in Parser implementations

Download history 5/week @ 2024-02-26 1/week @ 2024-03-11 68/week @ 2024-04-01

69 downloads per month

MIT/Apache

40KB
1K SLoC

Docs License

nomap

A parser for the .map file format used by Quake 1 & 2 as well as Half-Life 1, implemented using the nom parsing framework. It can easily be integrated with other nom parsers.

nomap is whitespace agnostic and ignores comments. It also optionally provides Display implementations for all its types (through the "display" feature), so you can serialise a parsed map back into a string.

Example

// parse the example map with the standard format
let map = nomap::parse::<nomap::formats::Standard>(include_str!("../examples/example.map")).unwrap();

// report our findings
for ent in map.entities.iter() {
    println!(
        "Found entity of class `{}` with {} brush{}",
        // every entity should have this, so we optimistically index here
        ent.fields["classname"],
        ent.brushes.len(),
        // some fanciness
        if ent.brushes.len() == 1 { "" } else { "es" }
    )
}

Dependencies

~1MB
~16K SLoC