Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thautwarm/gkdbnf
convert bnf files, to LaTex notations, supporting multiple LaTex BNF packages as back ends
https://github.com/thautwarm/gkdbnf
bnf code-generation latex
Last synced: 3 months ago
JSON representation
convert bnf files, to LaTex notations, supporting multiple LaTex BNF packages as back ends
- Host: GitHub
- URL: https://github.com/thautwarm/gkdbnf
- Owner: thautwarm
- License: mit
- Created: 2020-01-08T12:24:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-03T15:37:07.000Z (about 4 years ago)
- Last Synced: 2024-09-29T05:03:58.777Z (3 months ago)
- Topics: bnf, code-generation, latex
- Language: Python
- Homepage:
- Size: 154 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GKD-BNF
`pip install gkdbnf`.
Maybe the most simplest way to write pretty BNF in LaTex.
Use this package with `gkdtex`:
## Usage
```tex
\gkd@bnf{
:: Integer
:: Symbol
:: String:: !Expr[MinDyn]! = \mathbf{func} (\! \!) \{ \} %%% functions
| ( ) %%% applications
| = %%% assignments
| \mathbf{if} ( ) \{ \} \{ \} %%% conditions
| %%% variable read
|
|::=
| \mathbf{const} =
::=
}
```![example0.PNG](example0.PNG)
## Syntax
Valid BNF Syntax:
```bnf
atom ::= NONTERMINAL
| TERMINAL
| TERMINAL2
| '|'rule ::= '%%%' TERMINAL2
description ::= TERMINAL | TERMINAL2
type ::= TERMINAL | TERMINAL2 | NONTERMINALprod ::= 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
```tex
1: \gkd@usepackage{gkdbnf}
2: \gkd@bnf{
3: ::= a + 1
4:
5: ::= 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 `.