TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 230 subscribers
Post #25408 13
Tau Parser - a parsing library for C++ for Boolean grammars (CFG + conjunction + negation)

[https://github.com/IDNI/parser](https://github.com/IDNI/parser)

Tau Parser handles Boolean grammars: context-free, conjunction and negation. You can write something like `identifier & ~keyword` directly in the grammar to match any identifier that isn't a reserved word. No separate lexer hack, no keyword table living in your host code.

The grammar format (TGF) is EBNF-like and readable. Here's keyword-exclusion in practice:

identifier => (alpha | '_') (alnum | '_')* & ~keyword.
keyword => "let" | "if" | "else" | "while" | "fn" | "return".

* Earley-based, so left recursion works, no grammar refactoring.
* Handles ambiguity natively (full parse forest available), but auto-disambiguation gives you a single tree by default with zero configuration. You can switch it off per-nonterminal when you actually want the alternatives.
* Header-only after codegen. Run `tgf calc.tgf gen`, include the generated header, and parse:



auto r = calc_parser::instance().parse(input, len);
if (r.found) r.get_tree()->to_print(std::cout);

* The `tgf` CLI also ships an interactive REPL and a test runner for `.tgf.test` files with tree-shape assertions.
* Tree shaping (`@trim`, u/inline) lets you strip whitespace/punctuation and collapse wrapper nodes so you get a clean AST.
* Platform parity across Linux, macOS, Windows (mingw-w64), and WASM/Emscripten.

Boolean grammars can also express some things beyond context-free e.g. requiring two productions to derive the *same* string, or asserting a span does *not* match a production — so certain constraints that'd normally need a separate validation pass live in the grammar instead.

**Status:** alpha, under active development toward 1.0.

https://redd.it/1u3frd5
@r_cpp
GitHub GitHub - IDNI/parser: IDNI's parser library IDNI's parser library. Contribute to IDNI/parser development by creating an account on GitHub.
More from @r_cpp
  1. Sep 29, 2026Boost.Graph 1.95 will be C++17 Dear Boost.Graph community, In two release cycles (Boost re…
  2. Sep 26, 2026Token Sequence Injection & Modern Macros: The Most Game-Changing Compile-Time Feature in C…
  3. Sep 25, 2026myStringStream.str("") Considered Harmful Under C++20 I was recently looking at some (rath…
  4. Sep 20, 2026A clever branch free optimization I'm the developer of memlz which is an extremely fast co…
  5. Sep 15, 2026Inside Boost.PolyCollection https://bannalia.blogspot.com/2026/09/inside-boostpolycollecti…
  6. Sep 11, 2026C++26: Standard Library Hardening Experiments https://www.cppstories.com/2026/hardening-ex…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →