ReBNF: Regexes for Extended Backus-Naur Form
Project description
ReBNF
ReBNF (Regexes for Extended Backus-Naur Form) is a notation used to define the syntax of a language using regular expressions.
It is an extension of the EBNF (Extended Backus-Naur Form) notation, allowing for more flexibility and ease of use.
ooooooooo. oooooooooo. ooooo ooo oooooooooooo
`888 `Y88. `888' `Y8b `888b. `8' `888' `8
888 .d88' .ooooo. 888 888 8 `88b. 8 888
888ooo88P' d88' `88b 888oooo888' 8 `88b. 8 888oooo8
888`88b. 888ooo888 888 `88b 8 `88b.8 888 "
888 `88b. 888 .o 888 .88P 8 `888 888
o888o o888o `Y8bod8P' o888bood8P' o8o `8 o888o
Table of Contents
Syntax
The ReBNF notation uses regular expressions to define the structure of a
language. Each rule consists of a left-hand side (non-terminal) and a
right-hand side separated by an assignment operator (either ::=
, :=
or =
).
The general syntax of a ReBNF rule is as follows:
<alnum> ::= r"[a-zA-Z0-9]" ; # any alphanumeric characters
Example
Here's a short example of a ReBNF definition for a simple arithmetic expression language:
expression = term { ('+' | '-') term }
term = factor { ('*' | '/') factor }
factor = number | expression
number = r'\d+'
Usage
ReBNF notation is used to define the syntax of programming languages, configuration file formats, or any other formal language.
It provides a concise and powerful way to express language structures with a addition of regular expressions.
Note that the functions in this module are only designed to parse syntactically valid ReBNF code (code that does not raise when parsed using
parse()
). The behavior of the functions in this module is undefined when providing invalid ReBNF code and it can change at any point.
Contributing
Contributions are welcome! If you have suggestions, improvements, or new ideas related to the ReBNF notation, please feel free to open an issue or submit a pull request.
License
This project is licensed under the GPLv3 license - see LICENSE.md for details..
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rebnf-0.6.tar.gz
.
File metadata
- Download URL: rebnf-0.6.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f02360ec97b19e300761b9f37a3f6ab3547b89a748617e626b277024c8cbcd1f |
|
MD5 | 8ffe90f126d37643e0acce83a276fc5e |
|
BLAKE2b-256 | 527b6d636832c53d6d5fd572c920398ca993d3440bdf24b0456c8285293c22f6 |
File details
Details for the file rebnf-0.6-py2.py3-none-any.whl
.
File metadata
- Download URL: rebnf-0.6-py2.py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8deb55333ef269eef93f4509de1439c4af9e75b341aab56c09dffe4f28794d3d |
|
MD5 | 45111e765a2dca9c5903c3b936ee2657 |
|
BLAKE2b-256 | bce4738a6866ac7d7bdb106cb19ab7a6c1cf4cdbcb57210b097a91eb2a619177 |