formal grammar teaching toolkit
Project description
Formgram is a toolkit for teaching and or learning formal grammars with a focus on exploring the code and experimenting with and on it.
Students can use it to verify their findings in exercise problems and to understand taught algorithms by looking at their implemented form (and experimenting on them to see where those might break).
Teachers can use it to teach algorithms in their implemented form as an alternative to pure mathematical pseudocode.
>>> from formgram.classes.grammar import new_grammar >>> grammar_string = \ >>> """ # A simple context free grammar >>> <Sentence> ::= <Subject> " " <Verb> " " <Object> >>> <Subject> ::= <Noun> >>> <Object> ::= <Noun> >>> <Verb> ::= "bites" | "adores" >>> <Noun> ::= "Human" | "Dog" | "Cat" >>> """ >>> grammar = new_grammar(grammar_string) >>> type(grammar) formgram.classes.grammar.ContextFreeGrammar
Installing Formgram and Supported Versions
Formgram is available on PyPI:
$ python -m pip install formgram
Formgram is written and tested on Python 3.8 and should work on any later version.
Features
Formgram is created to enable working with formal grammars in context of a lecture on formal languages. It
Determine Chomsky hierarchy level
Determine grammar normal forms
Import/export grammars to string format
Transform to and from corresponding machines
API Reference and User Guide available on gwdg pages
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.