Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABNF grammar support V2 #1022

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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