Skip to main content

formal grammar teaching toolkit

Project description

PyPI download month PyPI pyversions PyPI license PyPI status

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 Grammar
>>> grammar_string = \
>>> """ # A simple context free grammar
>>> <Sentence> ::= <Subject> " " <Verb> " " <Object>
>>> <Subject> ::= <Noun>
>>> <Object> ::= <Noun>
>>> <Verb> ::= "bites" | "adores"
>>> <Noun> ::= "Human" | "Dog" | "Cat"
>>> """
>>> grammar = Grammar.from_str(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.

Source Distribution

formgram-0.0.4.tar.gz (56.7 kB view hashes)

Uploaded Source

Built Distribution

formgram-0.0.4-py3-none-any.whl (151.0 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