Context-free grammars and parsing
Project description
cfgrammar : Context-free grammars, parsing and semantic
Table of Contents
Main features
- Grammar properties
- accessible and productive rules / variables
- ε-productive rules / variables
- reduced grammar
- "First" and "Follow" sets
- LL1 parsing
- computes and displays LL(1) table
- constructs parser
- LR parsing
- computes and displays LR(0) automaton
- constructs LR(0), SLR(1), LALR(1) tables and parsers
- Semantic
- parsing with semantic actions
- Abstract Syntax Tree
- predefined semantic classes to produce AST
- Graphviz / dot output
- Latex + Tikz output
- predefined semantic classes to produce AST
Example
Code :
from cfgrammar import Grammar
g = Grammar.from_string('S -> ( S ) S | a')
print(g)
print('productives variables : ', g.productive.vars)
print('Follow sets : ', g.follow)
print(g.tableLL1().to_markdown())
Output:
Grammar(
terminals : ( ) a
variables : S
axiom : S
rules : ['S → ( S ) S', 'S → a']
)
productives variables : {'S'}
Follow sets : {'S': {')', '#'}}
| | S |
|:---|:------------|
| ( | S → ( S ) S |
| ) | |
| a | S → a |
| # | |
API overall graph
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
cfgrammar-0.1.1.1.tar.gz
(37.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cfgrammar-0.1.1.1.tar.gz.
File metadata
- Download URL: cfgrammar-0.1.1.1.tar.gz
- Upload date:
- Size: 37.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52329c36d5eac38ffb0c55c87d8caa4e1f01233b570ed18f77d067432f95ed90
|
|
| MD5 |
826206ac06ff2d46dc524384b116d7f8
|
|
| BLAKE2b-256 |
ac7ca83849c494ca7229bbc295f6f5003f39634f309d4592315f2db422c26e7b
|
File details
Details for the file cfgrammar-0.1.1.1-py3-none-any.whl.
File metadata
- Download URL: cfgrammar-0.1.1.1-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
046636a3c4278f3489143e333cd0a83043fae3da3909ac5c8e0148ec73d49bd4
|
|
| MD5 |
2b2aa6666d0d9eef7f424655aa88bca5
|
|
| BLAKE2b-256 |
3aa12cfee22017264a1febbb6c82b669700e1a38a57d7d9a758e412693bbf93c
|