Skip to main content

No project description provided

Project description

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

}

example.PNG

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>.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

gkdbnf-0.4.2-py3-none-any.whl (12.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page