gkdbnf


Namegkdbnf JSON
Version 0.4.2 PyPI version JSON
download
home_pagehttps://github.com/thautwarm/gkdbnf
Summary
upload_time2020-12-03 12:29:46
maintainer
docs_urlNone
authorthautwarm
requires_python>=3.7.0
licensemit
keywords latex bnf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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{
<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](example.PNG)

## Syntax


Valid BNF Syntax:
```bnf
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
```tex 
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>`.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thautwarm/gkdbnf",
    "name": "gkdbnf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.0",
    "maintainer_email": "",
    "keywords": "LaTex,BNF",
    "author": "thautwarm",
    "author_email": "twshere@outlook.com",
    "download_url": "",
    "platform": "any",
    "description": "# GKD-BNF\n\n`pip install gkdbnf`.\n\nMaybe the most simplest way to write pretty BNF in LaTex.\n\nUse this package with `gkdtex`:\n\n## Usage\n\n```tex\n\\gkd@bnf{\n<i, j> :: Integer\n<b> :: Boolean\n<l> :: Labels\n\n\n!Instructions! <h> :: !Instr[MinSIL]! = \\mathbf{load} \\; i         %%% \\qquad  \\qquad  describe load \n                                     |  \\mathbf{store} \\; i\n                                     |  \\mathbf{push} \\; \\zeta \n                                     |  \\mathbf{pop}\n                                     |  \\mathbf{jump\\mbox{-}if} l %%%   consume TOS.\n                                     |  \\cdots\n\n<e> ::= <e> ( <e> * ) |  atom\n\n}\n```\n\n![example.PNG](example.PNG)\n\n## Syntax\n\n\nValid BNF Syntax:\n```bnf\natom ::= NONTERMINAL\n       | TERMINAL\n       | TERMINAL2\n       | '|'\n\nrule        ::= '%%%' TERMINAL2\ndescription ::=  TERMINAL | TERMINAL2\ntype        ::= TERMINAL | TERMINAL2 | NONTERMINAL\n\nprod  ::= description? NONTERMINAL '::' type  '=' atom+ rule? \n      | '|' atom+ rule?\n\nstart ::= start NEWLINE\n      |   start prod\n      |   NEWLINE\n      |   prod\n```\n\n\nLexer rule by regex:\n```\nNEWLINE     = [\\r\\n]+\nNONTERMINAL = <.*?>\nTERMINAL2   = !.*?!\nTERMINAL    = \\S+\n```\n\nWhitespace tokens are ignored.\n\n## Nice Error Report\n```tex \n1:  \\gkd@usepackage{gkdbnf}\n2:  \\gkd@bnf{\n3:  <a> ::= a + 1\n4:\n5:  <c> ::= a a\n6:  Expressions e ::= e\n7: }\n```\n\nYou get error\n\n```\nSyntaxError: filename runtest/a.tex:\nline 6, column 13, NonTerm not match\n```\n\nThen you know you should change `Expression e` to `Expression <e>`.\n\n\n",
    "bugtrack_url": null,
    "license": "mit",
    "summary": "",
    "version": "0.4.2",
    "split_keywords": [
        "latex",
        "bnf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "2dec2cccab057899c8b6abc1d5405d8a",
                "sha256": "d4ad93229a488239c95a445a775792c1bbdd368273500b2a8837fd542833937b"
            },
            "downloads": -1,
            "filename": "gkdbnf-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2dec2cccab057899c8b6abc1d5405d8a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.0",
            "size": 12269,
            "upload_time": "2020-12-03T12:29:46",
            "upload_time_iso_8601": "2020-12-03T12:29:46.512309Z",
            "url": "https://files.pythonhosted.org/packages/41/99/5826243fcd1971039e5a117e9907f9947f87c1e79f0297f8e35bc0439aca/gkdbnf-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-12-03 12:29:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "thautwarm",
    "error": "Could not fetch GitHub repository",
    "lcname": "gkdbnf"
}
        
Elapsed time: 0.15955s