tabnas-debug (Rust)
Debug / introspection plugin for the
tabnas parser engine, crate
tabnas-debug (library tabnas_debug).
It makes a grammar visible: describe dumps an instance's installed
grammar (tokens, rules, plugins) as labelled text, model returns the
same information as structured, serialisable data, abnf re-expresses it
as ABNF, and tracing logs a parse event by event. A dev/test aid, never
a runtime dependency.
This is the Rust port of the canonical TypeScript implementation in
../ts; the TypeScript version is authoritative and this crate
tracks it. The Rust engine exposes tracing and introspection through
different idioms, so the surface differs in shape: free functions
instead of instance methods, typed options instead of an option map, and
a use_plugin wrapper for the print option. See
the concepts doc and reference for
the details, and ../docs/reference.md for the
authoritative cross-runtime divergence register.
Install
The engine is on crates.io as tabnas-parser, whose library is named
tabnas in code, and so is this crate, as tabnas-debug. The examples
below name both, so add both:
This repository's own Cargo.toml is not the published one: it takes the
engine by path from a sibling checkout, so a build here needs
https://github.com/tabnas/parser cloned beside it. The release workflow
swaps that path for a crates.io version when it publishes the crate.
Use
use Tabnas;
use ;
describe, model and abnf read a live instance and have no side
effects, so they work on any Tabnas whether or not the plugin is
installed. Installing the plugin is what turns on tracing and the USE:
dump.
To capture output instead of writing it to stderr, set the engine's sink:
# let mut parser = new;
parser.options.debug.output = Some;
Documentation
- Tutorial. Zero to a working inspection, step by step.
- How-to guide. Focused recipes.
- Reference. The exact exports, options, and output.
- Concepts. How it works and how it differs from the TypeScript version.
Build and test
The engine is a path dependency on the sibling checkout, so there is nothing to fetch and nothing to build first:
Or, from the repository root, make test-rs runs the tests and Clippy.
There is only one resolution here, always the sibling engine, unlike
the Go module's pinned/workspace pair.
The suite runs the shared ../test/spec/*.tsv conformance fixtures (the
same files the TypeScript and Go suites run) over the same named
grammars. A row green in one runtime and red in another is a failure, not
a discrepancy.
License
MIT.