C# implementation of the Links Notation parser using Pegasus parser generator and Platform.Collections.
Install-Package Link.Foundation.Links.Notation
dotnet add package Link.Foundation.Links.Notation<PackageReference Include="Link.Foundation.Links.Notation" Version="0.9.0" />Clone the repository and build:
git clone https://github.com/link-foundation/links-notation.git
cd links-notation/csharp
dotnet build Link.Foundation.Links.Notation.slnRun tests:
dotnet testusing Link.Foundation.Links.Notation;
// Create parser
var parser = new Parser();
// Parse Links Notation format string
string input = @"papa (lovesMama: loves mama)
son lovesMama
daughter lovesMama
all (love mama)";
var links = parser.Parse(input);
// Access parsed links
foreach (var link in links)
{
Console.WriteLine(link.ToString());
}using Link.Foundation.Links.Notation;
// Format links back to string
string formatted = links.Format();
Console.WriteLine(formatted);// Create link programmatically
var link = new Link<string>("id", new[] { "value1", "value2" });
// Access link properties
Console.WriteLine($"ID: {link.Id}");
foreach (var value in link.Values)
{
Console.WriteLine($"Value: {value}");
}// Using numeric link addresses
var parser = new Parser<ulong>();
var numericLinks = parser.Parse("(1: 2 3)");
// Working with custom address types
var customParser = new Parser<Guid>();papa (lovesMama: loves mama)
son lovesMama
daughter lovesMama
all (love mama)
papa has car
mama has house
(papa and mama) are happy
(linksNotation: links notation)
(This is a linksNotation as well)
(linksNotation supports (unlimited number (of references) in each link))
- Parser<TLinkAddress>: Main parser class for converting strings to links
- Link<TLinkAddress>: Represents a single link with ID and values
- LinksGroup<TLinkAddress>: Container for grouping related links
- IListExtensions.Format(): Converts list of links back to string format
- ILinksGroupListExtensions: Additional operations for link groups
Check code formatting:
dotnet format --verify-no-changes --verbosity diagnosticAuto-fix formatting:
dotnet formatThis project uses pre-commit hooks. To set up pre-commit hooks locally:
# From repository root
pip install pre-commit
pre-commit installNote: C# formatting checks are integrated into the CI pipeline using
dotnet format.
- .NET 8.0
- Microsoft.CSharp (4.7.0)
- Pegasus (4.1.0)
- Platform.Collections (0.3.2)
This project uses dotnet format for code formatting.
dotnet formatdotnet format --verify-no-changesThese checks are also enforced in CI. Pull requests with formatting issues will fail the format check.
For complete API documentation, visit: Link.Foundation.Links.Notation Documentation