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.5.tar.gz
.
File metadata
- Download URL: rebnf-0.5.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af609798c7cbbb6eadf62213ea7aab67e954d052cceeece1408cf3b37bc58553 |
|
MD5 | f95cabd4353e08e2bc8d4e6b63e38aa1 |
|
BLAKE2b-256 | 73c250c890e19ac01579533fa98c375d7b270c17eee8bb8234e31b65c9c94dd6 |
File details
Details for the file rebnf-0.5-py2.py3-none-any.whl
.
File metadata
- Download URL: rebnf-0.5-py2.py3-none-any.whl
- Upload date:
- Size: 18.8 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 | 4a48612af3aede837532d3cad3cafaee8907ff12f6ab2d572471cd947b1278d3 |
|
MD5 | e1bc97eed8e7d3e2caccd8472c2cf2b0 |
|
BLAKE2b-256 | febb2256606b798defd06353cfa5a867a530bf0adb842de8084156b13af88f15 |