diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-13 00:40:55 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-13 00:48:25 +0100 |
| commit | 4c222dd26acb12ce20e0513653595f07dc38db2e (patch) | |
| tree | 9074396e4ea8c0695490d3451cda77609a6bebff | |
| parent | 1fec7e9fba5aace20e0b5c5463eca9c0d0692f51 (diff) | |
Update README1.0.0
| -rw-r--r-- | README.md | 126 |
1 files changed, 72 insertions, 54 deletions
@@ -1,19 +1,21 @@ # WMAP Parser for C -A parser for `wmap` formatted Wardley Map files in ANSI C, with 68k and PPC mac support. +A parser for `wmap` formatted Wardley Map files in ANSI C. ## Features -- **ANSI C Compatible**: Works with older compilers and hardware -- **Complete Coverage**: Supports all `wmap` entities (components, dependencies, notes, stages, groups, inertia, evolution) +* ANSI C Compatible. Should work with ANSI compatible compilers. (e.g THINK C 5 for 68k macs) +* Single .h/.c that's easy to include. +* Free software. +* Reasonably Fast. -## Quick Start +## Usage ```c #include <wmap_parser.h> int main() { - // Parse from file + // Parse from file. (See also: wmap_parse_string) wmap_map_t* map = wmap_parse_file("example.wmap"); if (!map) { printf("Failed to parse file\n"); @@ -40,32 +42,78 @@ int main() { ## Build Instructions -### Library Build ```bash make # Build release version -> ./build/release/ make debug # Build debug version -> ./build/debug/ -make test # Test with example.wmap (uses current build) -make benchmark # Performance benchmark (100 iterations default) -make -e ITERATIONS=1000 benchmark # Custom iteration count ``` -### Setting Configuration -You can pass the CONFIGURATION environment variable to control which version -is used. This applies to test and benchmark as well. +## Format Specification + +See [The map website](https://map.tranquil.systems) for more information on the +format. + +## Reasonably Fast + +Benchmarked on an M1 Pro mac. A map with around 120 entities parses in 7µs. +While a larger map with slightly under 2000 entities does so in 155µs. + +You can run the benchmarks by using: + ```bash -make -e CONFIGURATION=debug # Debug build via environment variable +make benchmark ``` -### Development +You can specify how many iterations. + +```bash +make -e ITERATIONS=1000 benchmark # Custom iteration count +``` +## Running Tests + +```bash +make test +``` + +## More Commands ```bash -make debug # Debug build with symbols make memtest # Memory leak testing (uses debug build) make clean # Remove all build artifacts (./build/ directory) make info # Show build configuration and available targets ``` -## Data Structures +## Memory Limits + +| Entity Type | Maximum Count | +|--------------|----------------| +| Components | 1024 | +| Dependencies | 2048 | +| Notes | 256 | +| Groups | 128 | +| Inertias | 256 | +| Evolutions | 256 | +| Name Length | 64 characters | +| Text Length | 256 characters | + +## API Reference + +### Core Functions + +```c +// Parse from string +wmap_map_t* wmap_parse_string(const char* input); + +// Parse from file +wmap_map_t* wmap_parse_file(const char* filename); + +// Free parsed map +void wmap_map_free(wmap_map_t* map); + +// Validate input size and format +int wmap_validate_input(const char* input, size_t max_size); +``` + +### Data Structures ```c typedef struct { @@ -101,47 +149,17 @@ typedef struct { } wmap_dependency_t; ``` -## Memory Limits - -| Entity Type | Maximum Count | -|-------------|---------------| -| Components | 1024 | -| Dependencies | 2048 | -| Notes | 256 | -| Groups | 128 | -| Inertias | 256 | -| Evolutions | 256 | -| Name Length | 64 characters | -| Text Length | 256 characters | - -## Performance - -- **Parsing Speed**: 32,000+ parses/second -- **Memory Usage**: Fixed allocation, no dynamic memory during parsing -- **File Size Limit**: 10MB maximum for safety -- **Input Validation**: Automatic bounds checking and malformed input handling - -## API Reference - -### Core Functions - -```c -// Parse from string -wmap_map_t* wmap_parse_string(const char* input); - -// Parse from file -wmap_map_t* wmap_parse_file(const char* filename); - -// Free parsed map -void wmap_map_free(wmap_map_t* map); - -// Validate input size and format -int wmap_validate_input(const char* input, size_t max_size); -``` - ### Error Handling - Functions return `NULL` on failure - Input validation prevents buffer overflows - Malformed lines are skipped, parsing continues - File size limits prevent excessive memory usage + +## See Also + +- [wmap specification](doc/wmap-spec.ebnf) - Formal grammar +- [wmap specification](https://git.sr.ht:~rbdr/wmap-parser-js) - Javascript wmap-parser +- [wmap specification](https://git.sr.ht:~rbdr/wmap-parser-rust) - Rust wmap-parser +- [wmap specification](https://git.sr.ht:~rbdr/wmap-parser-swift) - Swift wmap-parser +- [Wardley Maps](https://wardleymaps.com/) - Learn about Wardley Mapping |