GKD-BNF
pip install gkdbnf.
Maybe the most simplest way to write pretty BNF in LaTex.
Use this package with gkdtex:
Usage
\gkd@bnf{
<i, j> :: Integer
<b> :: Boolean
<l> :: Labels
!Instructions! <h> :: !Instr[MinSIL]! = \mathbf{load} \; i %%% \qquad \qquad describe load
| \mathbf{store} \; i
| \mathbf{push} \; \zeta
| \mathbf{pop}
| \mathbf{jump\mbox{-}if} l %%% consume TOS.
| \cdots
<e> ::= <e> ( <e> * ) | atom
}
Syntax
Valid BNF Syntax:
atom ::= NONTERMINAL
| TERMINAL
| TERMINAL2
| '|'
rule ::= '%%%' TERMINAL2
description ::= TERMINAL | TERMINAL2
type ::= TERMINAL | TERMINAL2 | NONTERMINAL
prod ::= description? NONTERMINAL '::' type '=' atom+ rule?
| '|' atom+ rule?
start ::= start NEWLINE
| start prod
| NEWLINE
| prod
Lexer rule by regex:
NEWLINE = [\r\n]+
NONTERMINAL = <.*?>
TERMINAL2 = !.*?!
TERMINAL = \S+
Whitespace tokens are ignored.
Nice Error Report
1: \gkd@usepackage{gkdbnf}
2: \gkd@bnf{
3: <a> ::= a + 1
4:
5: <c> ::= a a
6: Expressions e ::= e
7: }
You get error
SyntaxError: filename runtest/a.tex:
line 6, column 13, NonTerm not match
Then you know you should change Expression e to Expression <e>.
Release files for gkdbnf 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gkdbnf-0.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Release files / gkdbnf-0.4.2-py3-none-any.whl
| Download URL | gkdbnf-0.4.2-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4ad93229a488239c95a445a775792c1bbdd368273500b2a8837fd542833937b
|
|
BLAKE2b-256 checksum How to use checksums |
41995826243fcd1971039e5a117e9907f9947f87c1e79f0297f8e35bc0439aca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|