This PR updates the grammar to a newer version and cleans up the code base by refactoring QueryExpression.
Changes:
Update the version of pest.
Update to new grammar for reachability queries.
Combine invariant and edge parser into one
Refactor QueryExpression to only have a variant for each query type so we can have exhaustive match statements instead of using _ => unreachable!(). This involves introducing SystemExpression, SaveExpression and StateExpression enums. (See changes in src/ModelObjects/representations.rs)
The refactor is very nice because we can now rely on the type system with exhaustive match statements: If we add a new query type or composition type, we will get a compile error until we handle it in all match cases instead of getting runtime errors. And in general we won't miss match cases during development.
Also now simplifies the edge parser and deduplicates code and grammar by combining the edge and invariant parser. This works because invariants are equivalent to edge guards.
This PR updates the grammar to a newer version and cleans up the code base by refactoring
QueryExpression
. Changes:QueryExpression
to only have a variant for each query type so we can have exhaustive match statements instead of using_ => unreachable!()
. This involves introducingSystemExpression
,SaveExpression
andStateExpression
enums. (See changes insrc/ModelObjects/representations.rs
)The refactor is very nice because we can now rely on the type system with exhaustive match statements: If we add a new query type or composition type, we will get a compile error until we handle it in all match cases instead of getting runtime errors. And in general we won't miss match cases during development.
Also now simplifies the edge parser and deduplicates code and grammar by combining the edge and invariant parser. This works because invariants are equivalent to edge guards.