Skip to content

Conversation

t-higuchi
Copy link

This PR implements feature request #318 in different approach from PR #1017.

Now it parses ABNF grammar and convert it to EBNF parse-tree.
%import is implemented for convenience, and %terminal to control parse-tree construction.
These directives are non-standard extension to ABNF.

The first commit refactors GrammarBuilder into syntax independent GrammarLoaderBase and the rest so that
we can share/reuse code to implement %import for EBNF and ABNF (and other grammars).

Second commit is a plugin loader. It loads GrammarLoader instance as a plugin from lark/syntax/*.py.
These commits implements PR #1019 in different approach.

Following directives (%import and %terminal) are added as extensions
to ABNF grammar.

Syntax:
 %import module
 %import module (rule1, rule2, ...)
 %terminal rule1, rule2, ...

Example:
 %import core-rules       ; import rules from lark/grammars/core-rules.abnf
 %import core-rules (CRLF, DIGITS) ; import specified rules only
 %terminal CRLF           ; turn rule 'CRLF' into terminal
@t-higuchi t-higuchi mentioned this pull request Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant