Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci_extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
- name: Lint with pycodestyle
run: |
pycodestyle pyformlang || true
- name: Lint with ruff
run: |
ruff check pyformlang || true

- name: Check with pyright
run: |
pyright --stats pyformlang
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci_feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
- name: Lint with pycodestyle
run: |
pycodestyle pyformlang || true
- name: Lint with ruff
run: |
ruff check pyformlang || true

- name: Check with pyright
run: |
pyright --stats pyformlang
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ jobs:
- name: Lint with pycodestyle
run: |
pycodestyle pyformlang || true
- name: Lint with ruff
run: |
ruff check pyformlang || true

- name: Check with pyright
run: |
pyright --stats pyformlang
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,6 @@ prof/
*.report
.idea
pytest-coverage.txt

# VS Code config directory
.vscode
9 changes: 8 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
'sphinx.ext.viewcode'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -295,6 +294,14 @@
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

# Use type hints in both signature and description.
autodoc_typehints = "both"

# Use type annotations for documenting the return type.
napoleon_use_rtype = False

# Include documented special methods.
napoleon_include_special_with_doc = True

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
Expand Down
3 changes: 2 additions & 1 deletion doc/modules/context_free_grammar.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Context Free Grammar
Context-Free Grammar
====================

.. automodule:: pyformlang.cfg
:members:
:inherited-members:
5 changes: 3 additions & 2 deletions doc/modules/feature_context_free_grammar.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Feature Context Free Grammar
Feature Context-Free Grammar
============================

.. automodule:: pyformlang.fcfg
:members:
:members:
:inherited-members:
1 change: 1 addition & 0 deletions doc/modules/finite_automaton.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Finite Automaton

.. automodule:: pyformlang.finite_automaton
:members:
:inherited-members:
3 changes: 2 additions & 1 deletion doc/modules/fst.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Finite State Transducer
=======================

.. automodule:: pyformlang.fst
:members:
:members:
:inherited-members:
1 change: 1 addition & 0 deletions doc/modules/indexed_grammar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Indexed Grammar

.. automodule:: pyformlang.indexed_grammar
:members:
:inherited-members:
1 change: 1 addition & 0 deletions doc/modules/push_down_automata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Push-Down Automata

.. automodule:: pyformlang.pda
:members:
:inherited-members:
1 change: 1 addition & 0 deletions doc/modules/regular_expression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Regular Expression

.. automodule:: pyformlang.regular_expression
:members:
:inherited-members:
1 change: 1 addition & 0 deletions doc/modules/rsa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Recursive State Automaton

.. automodule:: pyformlang.rsa
:members:
:inherited-members:
8 changes: 5 additions & 3 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
sphinx_rtd_theme
networkx
numpy
pytest
pytest-cov
pytest-profiling
numpydoc
setuptools
wheel
twine
networkx
sphinx_rtd_theme
numpy
pylint
pycodestyle
ruff
pyright
pydot
pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability
pylint>=2.7.0 # not directly required, pinned by Snyk to avoid a vulnerability
Expand Down
65 changes: 35 additions & 30 deletions pyformlang/__init__.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
"""
Pyformlang
==========
Pyformlang is a python module to perform operation on formal languages.
"""Pyformlang is a python module to perform operation on formal languages.

:mod:`pyformlang`
=================

Available subpackages
---------------------
:mod:`~pyformlang.regular_expression`:
Regular Expressions.
:mod:`~pyformlang.finite_automaton`:
Finite Automata (deterministic, non-deterministic,
with/without epsilon transitions).
:mod:`~pyformlang.fst`:
Finite State Transducers.
:mod:`~pyformlang.cfg`:
Context-Free Grammars.
:mod:`~pyformlang.pda`:
Push-Down Automata.
:mod:`~pyformlang.indexed_grammar`:
Indexed Grammars.
:mod:`~pyformlang.rsa`:
Recursive Automata.
:mod:`~pyformlang.fcfg`:
Context-Free Grammars with Features.

How to use the documentation
----------------------------
Documentation is available in two formats: docstrings directly
in the code and a readthedocs website: https://pyformlang.readthedocs.io.
Available subpackages
---------------------
regular_expression
Regular Expressions
finite_automaton
Finite automata (deterministic, non-deterministic, with/without epsilon
transitions
fst
Finite State Transducers
cfg
Context-Free Grammar
pda
Push-Down Automata
Indexed Grammar
Indexed Grammar
rsa
Recursive automaton

"""

from . import finite_automaton
Expand All @@ -36,11 +39,13 @@
from . import fcfg


__all__ = ["finite_automaton",
"regular_expression",
"cfg",
"fst",
"indexed_grammar",
"pda",
"rsa",
"fcfg"]
__all__ = [
"finite_automaton",
"regular_expression",
"cfg",
"fst",
"indexed_grammar",
"pda",
"rsa",
"fcfg",
]
54 changes: 30 additions & 24 deletions pyformlang/cfg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
"""
"""This module implements functions related to context-free grammars.

:mod:`pyformlang.cfg`
=====================

This submodule implements functions related to context-free grammars.

Available Classes
-----------------

CFG
The main context-free grammar class
Production
A class to represent a production in a CFG
Variable
A context-free grammar variable
Terminal
A context-free grammar terminal
Epsilon
The epsilon symbol (special terminal)

:class:`~pyformlang.cfg.CFG`:
The main context-free grammar class.
:class:`~pyformlang.cfg.Production`:
A class to represent a production in a CFG.
:class:`~pyformlang.cfg.CFGObject`:
A general CFG object representation.
:class:`~pyformlang.cfg.Variable`:
A variable in context-free grammar.
:class:`~pyformlang.cfg.Terminal`:
A terminal in context-free grammar.
:class:`~pyformlang.cfg.Epsilon`:
The epsilon symbol (special terminal).
:class:`~pyformlang.cfg.ParseTree`:
A parse tree of the grammar.
:class:`~pyformlang.cfg.DerivationDoesNotExistError`:
An exception that occurs if the given word cannot
be derived from the grammar.
"""

from .cfg import CFG, CFGObject, Variable, Terminal, Epsilon, Production
from .parse_tree import ParseTree, DerivationDoesNotExist
from .parse_tree import ParseTree, DerivationDoesNotExistError


__all__ = ["CFGObject",
"Variable",
"Terminal",
"Epsilon",
"Production",
"CFG",
"ParseTree",
"DerivationDoesNotExist"]
__all__ = [
"CFG",
"Production",
"CFGObject",
"Variable",
"Terminal",
"Epsilon",
"ParseTree",
"DerivationDoesNotExistError",
]
Loading