cfpq_data.grammars.readwrite.rsa#
Read (and write) a Recursive State Automaton from (and to) different sources.
Functions
|
Create a Recursive State Automaton [1] from text. |
|
Create a Recursive State Automaton [1] from TXT file. |
|
Turns a Recursive State Automaton [1] into its text representation. |
|
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:
- textstr
The text with which the Recursive State Machine will be created.
- start_symbolSymbol
Start symbol of a Recursive State Machine.
- Returns:
- rsaRSA
Recursive State Automaton.
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
Examples
>>> from cfpq_data import * >>> rsa = rsa_from_text("S -> a*") >>> cfg_to_text(cfg_from_rsa(rsa)) 'S -> \nS -> a S'
- rsa_from_txt(path: Path | str, *, start_symbol: Symbol = S) RecursiveAutomaton[source]#
Create a Recursive State Automaton [1] from TXT file.
- Parameters:
- pathUnion[Path, str]
The path to the TXT file with which the Recursive State Machine will be created.
- start_symbolSymbol
Start symbol of a Recursive State Machine.
- Returns:
- rsaRSA
Recursive State Automaton.
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
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)*'
- rsa_to_text(rsa: RecursiveAutomaton) str[source]#
Turns a Recursive State Automaton [1] into its text representation.
- Parameters:
- rsaRSA
Recursive State Automaton.
- Returns:
- textstr
Recursive State Automaton text representation.
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
Examples
>>> from cfpq_data import * >>> rsa = rsa_from_text("S -> a*") >>> rsa_to_text(rsa) 'S -> (a)*'
- rsa_to_txt(rsa: RecursiveAutomaton, path: Path | str) Path[source]#
Saves a Recursive State Automaton text representation into TXT file.
- Parameters:
- rsaRSA
Recursive State Automaton.
- pathUnion[Path, str]
The path to the TXT file where Recursive State Machine text representation will be saved.
- Returns:
- pathPath
The path to the TXT file where Recursive State Automaton text representation will be saved.
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
Examples
>>> from cfpq_data import * >>> rsa = rsa_from_text("S -> (a S* b S*)*") >>> path = rsa_to_txt(rsa, "test.txt")