EBNFMaxing 0.2.0
dotnet add package EBNFMaxing --version 0.2.0
NuGet\Install-Package EBNFMaxing -Version 0.2.0
<PackageReference Include="EBNFMaxing" Version="0.2.0" />
<PackageVersion Include="EBNFMaxing" Version="0.2.0" />
<PackageReference Include="EBNFMaxing" />
paket add EBNFMaxing --version 0.2.0
#r "nuget: EBNFMaxing, 0.2.0"
#:package EBNFMaxing@0.2.0
#addin nuget:?package=EBNFMaxing&version=0.2.0
#tool nuget:?package=EBNFMaxing&version=0.2.0
<p align="center"> <img src="resources/images/longlogo.svg" alt="EBNFMaxing" width="400"> </p>
EBNFMaxing
Generate sentences from grammar rules and input tokens.
EBNFMaxing is a .NET library that turns an EBNF grammar and a stream of tokens into output text. Define your grammar, feed it data (string, JSON, or tokens), and get a generated result.
What is it?
Imagine you have a template for how sentences should be built — optional parts, repeated sections, choices between alternatives. EBNFMaxing lets you express that template as a grammar and then run it against real data.
You write rules. You provide input. You get output.
- Grammar — EBNF-like rules: optional blocks
[...], choices(...|...), loops{...}, and semantic actions that consume tokens and stack values - Input — A string (each char → token), a JSON object, or a stack of key/value tokens
- Output — A string, JSON, or a deserialized object via
Produce<T>
It’s a general-purpose sentence generator: useful for templating, DSL output, code generation, or any scenario where structure is driven by grammar rules.
Quick start
using Grammars;
using Grammars.Extensions;
var grammar = new GrammarEbnf();
grammar.AddProduction("A = (<a> | <b>)(<a> | <b>)(<a> | <\"c>)");
var result = grammar.ProduceString("ab");
// result == "abc"
Three lines: create the grammar, add a production, produce. That’s it.
Installation
dotnet add package EBNFMaxing
Or in your .csproj:
<PackageReference Include="EBNFMaxing" Version="0.2.0" />
A taste of the syntax
| Concept | Syntax | What it does |
|---|---|---|
| Consume a token | <key> |
Matches token by key, stacks its value |
| Static literal | <"value"> |
Stacks a fixed string (no token consumed) |
| Optional block | [content] |
Runs 0 or 1 time if the first action matches |
| Choice | (a \| b \| c) |
Picks the first branch that matches |
| Loop | {content} |
Repeats while the first action matches |
| Call production | :Name: |
Invokes another production |
For the full picture, see the Wiki.
Example
Grammar: A = <x>[<"-"><y>] — x plus an optional -y part
Input: {"x":"foo","y":"bar"} → Output: "foo-bar"
Input: {"x":"foo"} → Output: "foo"
Learn more
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.