Build Status Platforms Matrix

Gramophone

用于处理扩展巴科斯-诺尔范式 (EBNF) 符号和由此产生的语法的 Swift 库。

特性

警告

此库仍在开发中。 肯定仍然存在一些问题。

集成

Swift Package Manager

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

支持的语法

single_quote_terminal = 'value';
angled_quote_terminal = `value´;
double_quote_terminal = "value";
unicode_scalar = U+0000;
bnf_nonterminal = <value>;

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

arrow_assigment → a;
colon_colon_equals_assigment ::= a;

W3C 的 XQuery 规范也使用了很多额外的符号,值得研究。

用法

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

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

贡献与协作

我很乐意收到你的来信! Issues 或者 Pull Requests 都很好。 Matrix spaceDiscord 都提供在线帮助,但我强烈倾向于以文档的形式回答。 你也可以在 mastodon 上找到我。

我更喜欢协作,如果您有类似的项目,我很乐意找到合作的方式。

为了提高可访问性,我更喜欢用制表符进行缩进。 但是,我宁愿你使用你想要的系统并创建一个 PR,而不是因为空格而犹豫。

通过参与此项目,您同意遵守贡献者行为准则