Skip to content

Conversation

@bygu4
Copy link
Contributor

@bygu4 bygu4 commented Nov 28, 2024

Here we plan to rework the architecture of Pyformlang library, removing cyclic imports and hopefully making the design clearer. That would further allow us to add type annotations for most of the code, improving its rigor and readability as well as the interface of the project. For more detail, see issues:

@bygu4
Copy link
Contributor Author

bygu4 commented Nov 28, 2024

Rework several modules and their relations with adding type annotations. The following modules were affected:

  • finite_automaton,
  • regular_expression,
  • rsa,
  • cfg,
  • pda.

In more detail, we can describe the changes as follows.

finite_automaton:

  • Refactor automata transformations, including to_deterministic and remove_epsilon_transitions methods.
  • Move from_networkx to EpsilonNFA.
  • Rework transition functions of automata, adding DeterministicTransitionFunction class and TransitionFunction abstract class.
  • Refactor automata copying, add missing copy method for NFA.
  • Make FiniteAutomaton an abstract class.
  • Remove Regexable interface, implement automata union, concatenation and kleene star manually.
  • Add more methods for finite automata, including get_transitions_from, get_next_states_from, etc.
  • Add utils file for containing finite automata utility.

regular_expression:

  • Refactor automata to regex transformations, build regex from automata in Regex class.
  • Add copying of ENFA in to_epsilon_nfa method.
  • Add to_minimal_dfa method to Regex for using in recursive automata.

rsa:

  • Correct some properties and type annotations.

cfg and pda:

  • Define intersection with DFA explicitly.

@bygu4
Copy link
Contributor Author

bygu4 commented Feb 16, 2025

@Aunsiels
Please check out the following requests as well:

  1. Rework cfg FormalLanguageConstrainedPathQuerying/pyformlang#14 --- continue adding type annotations and refactoring;
  2. Rework indexed grammars FormalLanguageConstrainedPathQuerying/pyformlang#15 --- finish refactoring and adding annotations, add pyright to CI;
  3. Update documentation FormalLanguageConstrainedPathQuerying/pyformlang#16 --- set up Ruff, format and update all of the docstrings.

I would suggest creating a separate branch where we can try merging all of that

@bygu4 bygu4 marked this pull request as ready for review February 16, 2025 14:02
@bygu4 bygu4 force-pushed the rework_architecture branch from 94af59a to 1d1e8f1 Compare March 23, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant