Expand description
§Overview
This crate contains a complete Pest grammar for the mCRL2 specification language, along with functionality to consume the resulting parse tree into an abstract syntax tree (AST). As opposed to the mCRL2 toolset where the AST is represented by terms, we store the AST in a Rust-idiomatic way using enums and structs. This means that we potentially use more memory because there is no term sharing of expressions, but manipulating the AST is much easier.
§Usage
The mCRL2 specifications can simply be parsed using the untyped variants of the
various objects: UntypedProcessSpecification, UntypedDataSpecification, etc.
use merc_syntax::UntypedProcessSpecification;
let mcrl2_spec = UntypedProcessSpecification::parse("
act
a, b: Nat;
proc
P(n: Nat) = a(n).P(n + 1) + b(n).P(n - 1);
init
P(0);
").unwrap();§Changelog
§2.0
Added various builders and visitors to manipulate the ASTs.
Removed the arbitrary dependency since generating these expressions completely arbitrarily is not that useful.
§Safety
This crate contains no unsafe code.
§Minimum Supported Rust Version
We do not maintain an official minimum supported rust version (MSRV), and it may be upgraded at any time when necessary.
§License
All MERC crates are licensed under the BSL-1.0 license. See the LICENSE file in the repository root for more information.
Structs§
- ActDecl
- Action declaration
- Action
- Action
Rename Decl - Action
Rename Rule - Assignment
- BagElement
- Comm
Expr - Constructor
Decl - Constructor declaration
- Data
Expr Update - DeclTag
- A unique type for declarations.
- EqnDecl
- Equation declaration
- EqnSpec
- IdDecl
- A declaration of an identifier with its sort.
- Mcrl2
Parser - Multi
Action - Multi
Action Label - Represents a multi action label
a | b | c .... - Pbes
Equation - Pres
Equation - Proc
Decl - Process declaration
- Prop
VarDecl - Prop
VarInst - Rename
- Sort
Decl - Sort declaration
- Span
- Source location information, spanning from start to end in the source text.
- State
VarAssignment - State
VarDecl - Untyped
Action Rename Spec - Untyped
Data Specification - An mCRL2 data specification.
- Untyped
Pbes - An mCRL2 parameterised boolean equation system (PBES).
- Untyped
Pres - An mCRL2 parameterised boolean equation system (PBES).
- Untyped
Process Specification - A complete mCRL2 process specification.
- Untyped
State FrmSpec
Enums§
- ActFrm
- ActFrm
Binary Op - ActionRHS
- Aliased
Rule - Bound
- Complex
Sort - Complex (parameterized) sorts.
- Condition
- Data
Expr - Data expression
- Data
Expr Binary Op - Data
Expr Unary Op - Eq
- Fixed
Point Operator - Modality
Operator - Pbes
Expr - Pbes
Expr Binary Op - Pres
Expr - Pres
Expr Binary Op - Proc
Expr Binary Op - Process
Expr - Process expression
- Quantifier
- RegFrm
- Rule
- This contains the grammar for .mcrl2 specifications.
- Sort
- Built-in simple sorts.
- Sort
Expression - Expression representing a sort (type).
- State
Frm - State
FrmOp - State
FrmUnary Op
Statics§
- ACTFRM_
PRATT_ PARSER - Defines the operator precedence for action formulas using a Pratt parser.
- DATAEXPR_
PRATT_ PARSER - PROCEXPR_
PRATT_ PARSER - REGFRM_
PRATT_ PARSER - Defines the operator precedence for regular expressions using a Pratt parser.
- SORT_
PRATT_ PARSER
Functions§
- apply_
regular_ formula - Applies the given
functionrecursively to the regular formula. - apply_
sort_ expression - apply_
statefrm - Applies the given function recursively to the state formula.
- generate_
formula - Generates a formula that characterizes the counter example trace.
- parse_
actfrm - Parses a sequence of
Rulepairs into anActFrmusing a Pratt parser defined in ACTFRM_PRATT_PARSER for operator precedence. - parse_
action_ names - Parses a list of action names from the given input string, for example those used in the hide operator.
- parse_
allow_ action_ names - Parses the action names for the allow operator from the given input string.
- parse_
comm_ expr_ set - Parses a list of communication expressions from the given input string.
- parse_
dataexpr - parse_
pbesexpr - parse_
presexpr - parse_
process_ expr - parse_
regfrm - Parses a sequence of
Rulepairs into an RegFrm using a Pratt parser defined in REGFRM_PRATT_PARSER for operator precedence. - parse_
sortexpr - Parses a sequence of
Rulepairs into aSortExpressionusing a Pratt parser for operator precedence. - parse_
sortexpr_ primary - parse_
statefrm - print_
location - Prints location information for a span in the source.
- visit_
action_ formula - Visitor for action formulas.
- visit_
regular_ formula - Maps the given
functionrecursively to the regular formula. - visit_
sort_ expr - visit_
statefrm - Visits the state formula and calls the given function on each subformula.
Type Aliases§
- DeclId
- The index type for a label.