Updates to the pepapot library to allow for random testing. Mostly this means that the abstract syntax tree classes have constructors which accept the subtrees rather than a list of tokens. Hence the parser actions must extract out the correct tokens to pass to the constructors. Additionally the abstract syntax tree nodes now implement a 'format' method to allow a random model to be formatted such that it could then be parsed.
Also allow <> as the empty cooperation set in addition to ||
Added random testing to the tester. Currently only testing the parser
Fixed a silly bug in which a name was confused as a list of names. This was not highlighted before since all the names of processes were single letters in the tests. Now with the random tester this has been highlighted
Added the inspection of the generator matrix to the random model testing. This is quite nice because generator matrices have a couple of easily testable properties and it means we are testing the random models such that we know we are at least able to create a generator matrix from them.
Minor additions of blank lines to satisfy flake8 (and hence make lint)
Slight prettying of the code for getting components by factoring out the code to obtain the process definition which defines a given name
Removed the printing of parentheses around the formatting of a choice operator since I do not believe they are needed (and I've commented why in the source code).
Added choice operator to the random model testing.
Minor cleanup in tests/test_pepapot to satisfy flake8
Previously my random model testing was testing the same model 10 times, rather than generating 10 different models and testing each of those. Consequently it was something of a fluke if the test coverage was 100%. Now I generate 10 random models and it is somewhat unlikely that I don't (at the time of writing) achieve 100% code coverage using the random tests.
Removal of a blank line to satisfy flake8
Found a nice way of placing the grammar for a given node in the node's corresponding class definition. Additionally using a @classmethod I can have the method which chooses the correct tokens to pass to the constructor within the class definition. I think this organises the code somewhat better. It means there are fewer top-level definitions for one thing. Additionally I can keep the grammar and the 'from_tokens' methods next to one another, since updating one likely means you have to update the other.
A lot of tidying up of the parsing code in pepapot.pepapot. This is mostly using the trick of moving the grammar code (which defines the parser) for a given node kind defined within the class definition corresponding to the node kind. This means that the module namespace is not quite so cluttered. Which in turn means I can use slightly nicer names for sub-parts of the grammar since I have to worry less about clashing of names. This also uses the trick of a 'classmethod' to define the parser action for the given node kind (which will likely produce an instance of the class being defined). This is great because it means we can keep that parser action code next to the grammar defining code, because if you change the grammar you likely need to change the parser action.
Minor change to remove one of the globally imported names from pyparsing since it was only used in one place
Continued with the cleaning up of the parser code, moving the model grammar into the ParsedModel class
Added a test which ensures that we know what exception is raised when the model cannot be parsed. This is more mechanically checkable documentation than a real test.