Gramophone

main

Swift library for working with Extended Backus–Naur Form (EBNF) notation and grammars.
ChimeHQ/Gramophone

Build Status Platforms Discord

Gramophone

Swift library for working with Extended Backus–Naur Form (EBNF) notation and the resulting grammars.

Features:

  • Accepts a variety of BNF syntaxes
  • Computes FIRST and FOLLOW sets

⚠️ This library is still a work-in-progress. It definitely still has some issues.

Integration

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/ChimeHQ/Gramophone")
]

Supported Syntax

single_quote_terminal = 'value';
double_quote_terminal = "value";
unicode_scalar = U+0000;

concatenation = a, b, c;
implicit_concatenation = a b c;
alternation = a | b | c;
optional = [a, b];
tailing_optional = a?;
repetition = {a};
grouping = (a, b, c);
exception = a - b;

arrow_assigment → a;
colon_colon_equals_assigment ::= a;

Usage

let grammar = try parser.parseGrammar("test = 'a' | 'b';")

let firstMap = grammar.computeFirstMap()
let followMap = grammar.computeFollowMap()

Suggestions or Feedback

I would love to hear from you! Issues, Discussions, or pull requests work great. A Discord server is also available for live help, but I have a strong bias towards answering in the form of documentation.

I prefer collaboration, and would love to find ways to work together if you have a similar project.

I prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.

By participating in this project you agree to abide by the Contributor Code of Conduct.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

Last updated: Mon Mar 18 2024 09:31:25 GMT-0900 (Hawaii-Aleutian Daylight Time)