# cfgrammar : Context-free grammars, parsing and semantic #

## Table of Contents

- [Main Features](#main-features)
- [Example](#example)

## 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
  
## Example

```python
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)
```
