cfpq_data.grammars.readwrite.rsa#

Read (and write) a Recursive State Automaton from (and to) different sources.

Functions

rsa_from_text(text, *[, start_symbol])

Create a Recursive State Automaton [1] from text.

rsa_from_txt(path, *[, start_symbol])

Create a Recursive State Automaton [1] from TXT file.

rsa_to_text(rsa)

Turns a Recursive State Automaton [1] into its text representation.

rsa_to_txt(rsa, path)

Saves a Recursive State Automaton text representation into TXT file.

rsa_from_text(text: str, *, start_symbol: Symbol = S) RecursiveAutomaton[source]#

Create a Recursive State Automaton [1] from text.

Parameters:
  • text (str) -- The text with which the Recursive State Machine will be created.

  • start_symbol (Symbol) -- Start symbol of a Recursive State Machine.

Examples

>>> from cfpq_data import *
>>> rsa = rsa_from_text("S -> a*")
>>> cfg_to_text(cfg_from_rsa(rsa))
'S -> \nS -> a S'
Returns:

rsa -- Recursive State Automaton.

Return type:

RSA

References

[1] (1,2)

Alur R., Etessami K., Yannakakis M. (2001) Analysis of Recursive State Machines. In: Berry G., Comon H., Finkel A. (eds) Computer Aided Verification. CAV 2001. Lecture Notes in Computer Science, vol 2102. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44585-4_18

rsa_from_txt(path: Path | str, *, start_symbol: Symbol = S) RecursiveAutomaton[source]#

Create a Recursive State Automaton [1] from TXT file.

Parameters:
  • path (Union[Path, str]) -- The path to the TXT file with which the Recursive State Machine will be created.

  • start_symbol (Symbol) -- Start symbol of a Recursive State Machine.

Examples

>>> from cfpq_data import *
>>> rsa_1 = rsa_from_text("S -> a*")
>>> path = rsa_to_txt(rsa_1, "test.txt")
>>> rsa = rsa_from_txt(path)
>>> rsa_to_text(rsa)
'S -> (a)*'
Returns:

rsa -- Recursive State Automaton.

Return type:

RSA

References

[1] (1,2)

Alur R., Etessami K., Yannakakis M. (2001) Analysis of Recursive State Machines. In: Berry G., Comon H., Finkel A. (eds) Computer Aided Verification. CAV 2001. Lecture Notes in Computer Science, vol 2102. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44585-4_18

rsa_to_text(rsa: RecursiveAutomaton) str[source]#

Turns a Recursive State Automaton [1] into its text representation.

Parameters:

rsa (RSA) -- Recursive State Automaton.

Examples

>>> from cfpq_data import *
>>> rsa = rsa_from_text("S -> a*")
>>> rsa_to_text(rsa)
'S -> (a)*'
Returns:

text -- Recursive State Automaton text representation.

Return type:

str

References

[1] (1,2)

Alur R., Etessami K., Yannakakis M. (2001) Analysis of Recursive State Machines. In: Berry G., Comon H., Finkel A. (eds) Computer Aided Verification. CAV 2001. Lecture Notes in Computer Science, vol 2102. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44585-4_18

rsa_to_txt(rsa: RecursiveAutomaton, path: Path | str) Path[source]#

Saves a Recursive State Automaton text representation into TXT file.

Parameters:
  • rsa (RSA) -- Recursive State Automaton.

  • path (Union[Path, str]) -- The path to the TXT file where Recursive State Machine text representation will be saved.

Examples

>>> from cfpq_data import *
>>> rsa = rsa_from_text("S -> (a S* b S*)*")
>>> path = rsa_to_txt(rsa, "test.txt")
Returns:

path -- The path to the TXT file where Recursive State Automaton text representation will be saved.

Return type:

Path

References

[1]

Alur R., Etessami K., Yannakakis M. (2001) Analysis of Recursive State Machines. In: Berry G., Comon H., Finkel A. (eds) Computer Aided Verification. CAV 2001. Lecture Notes in Computer Science, vol 2102. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44585-4_18