1
use std::hash::Hash;
2

            
3
use merc_utilities::TagIndex;
4

            
5
/// A unique type for declarations.
6
pub struct DeclTag;
7

            
8
/// The index type for a label.
9
pub type DeclId = TagIndex<usize, DeclTag>;
10

            
11
/// A complete mCRL2 process specification.
12
#[derive(Debug, Default, Eq, PartialEq, Hash)]
13
pub struct UntypedProcessSpecification {
14
    pub data_specification: UntypedDataSpecification,
15
    pub global_variables: Vec<IdDecl>,
16
    pub action_declarations: Vec<ActDecl>,
17
    pub process_declarations: Vec<ProcDecl>,
18
    pub init: Option<ProcessExpr>,
19
}
20

            
21
/// An mCRL2 data specification.
22
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
23
pub struct UntypedDataSpecification {
24
    pub sort_declarations: Vec<SortDecl>,
25
    pub constructor_declarations: Vec<IdDecl>,
26
    pub map_declarations: Vec<IdDecl>,
27
    pub equation_declarations: Vec<EqnSpec>,
28
}
29

            
30
impl UntypedDataSpecification {
31
    /// Returns true if the data specification is empty.
32
    pub fn is_empty(&self) -> bool {
33
        self.sort_declarations.is_empty()
34
            && self.constructor_declarations.is_empty()
35
            && self.map_declarations.is_empty()
36
            && self.equation_declarations.is_empty()
37
    }
38

            
39
    /// Merges another data specification into the current one.
40
    pub fn merge(&mut self, other_spec: &UntypedDataSpecification) {
41
        self.sort_declarations.extend_from_slice(&other_spec.sort_declarations);
42
        self.constructor_declarations
43
            .extend_from_slice(&other_spec.constructor_declarations);
44
        self.map_declarations.extend_from_slice(&other_spec.map_declarations);
45
        self.equation_declarations
46
            .extend_from_slice(&other_spec.equation_declarations);
47
    }
48
}
49

            
50
/// An mCRL2 parameterised boolean equation system (PBES).
51
#[derive(Debug, Default, Eq, PartialEq, Hash)]
52
pub struct UntypedPbes {
53
    pub data_specification: UntypedDataSpecification,
54
    pub global_variables: Vec<IdDecl>,
55
    pub equations: Vec<PbesEquation>,
56
    pub init: PropVarInst,
57
}
58

            
59
/// An mCRL2 parameterised boolean equation system (PBES).
60
#[derive(Debug, Default, Eq, PartialEq, Hash)]
61
pub struct UntypedPres {
62
    pub data_specification: UntypedDataSpecification,
63
    pub global_variables: Vec<IdDecl>,
64
    pub equations: Vec<PresEquation>,
65
    pub init: PropVarInst,
66
}
67

            
68
#[derive(Debug, Eq, PartialEq, Hash)]
69
pub struct PropVarDecl {
70
    pub identifier: String,
71
    pub parameters: Vec<IdDecl>,
72
    pub span: Span,
73
}
74

            
75
impl PropVarDecl {
76
    /// Creates a new propositional variable declaration with the given identifier and parameters.
77
    pub fn new(identifier: String, parameters: Vec<IdDecl>) -> Self {
78
        PropVarDecl {
79
            identifier,
80
            parameters,
81
            span: Span::default(),
82
        }
83
    }
84
}
85

            
86
#[derive(Debug, Default, Eq, PartialEq, Hash)]
87
pub struct PropVarInst {
88
    pub identifier: String,
89
    pub arguments: Vec<DataExpr>,
90
}
91

            
92
impl PropVarInst {
93
    /// Creates a new instance of a propositional variable with the given identifier and arguments.
94
    pub fn new(identifier: String, arguments: Vec<DataExpr>) -> Self {
95
        PropVarInst { identifier, arguments }
96
    }
97
}
98

            
99
/// A declaration of an identifier with its sort.
100
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
101
pub struct IdDecl {
102
    /// Identifier being declared
103
    pub identifier: String,
104
    /// Sort expression for this identifier
105
    pub sort: SortExpression,
106
    /// Source location information
107
    pub span: Span,
108
    /// Unique ID assigned to this declaration during name resolution.
109
    pub id: Option<DeclId>,
110
}
111

            
112
impl IdDecl {
113
    /// Creates a new identifier declaration with the given identifier, sort, and span.
114
95865
    pub fn new(identifier: String, sort: SortExpression, span: Span) -> Self {
115
95865
        IdDecl {
116
95865
            identifier,
117
95865
            sort,
118
95865
            span,
119
95865
            id: None,
120
95865
        }
121
95865
    }
122
}
123

            
124
/// Expression representing a sort (type).
125
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
126
pub enum SortExpression {
127
    /// Product of two sorts (A # B)
128
    Product {
129
        lhs: Box<SortExpression>,
130
        rhs: Box<SortExpression>,
131
    },
132
    /// Function sort (A -> B)
133
    Function {
134
        domain: Box<SortExpression>,
135
        range: Box<SortExpression>,
136
    },
137
    Struct {
138
        inner: Vec<ConstructorDecl>,
139
    },
140
    /// Reference to a named sort    
141
    Reference(String),
142
    /// Built-in simple sort
143
    Simple(Sort),
144
    /// Parameterized complex sort
145
    Complex(ComplexSort, Box<SortExpression>),
146
}
147

            
148
/// Constructor declaration
149
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
150
pub struct ConstructorDecl {
151
    pub name: String,
152
    pub args: Vec<(Option<String>, SortExpression)>,
153
    pub projection: Option<String>,
154
}
155

            
156
/// Built-in simple sorts.
157
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
158
pub enum Sort {
159
    Bool,
160
    Pos,
161
    Int,
162
    Nat,
163
    Real,
164
}
165

            
166
/// Complex (parameterized) sorts.
167
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
168
pub enum ComplexSort {
169
    List,
170
    Set,
171
    FSet,
172
    FBag,
173
    Bag,
174
}
175

            
176
/// Sort declaration
177
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
178
pub struct SortDecl {
179
    /// Sort identifier
180
    pub identifier: String,
181
    /// Sort expression (if structured)
182
    pub expr: Option<SortExpression>,
183
    /// Where the sort is defined
184
    pub span: Span,
185
    /// Unique ID assigned to this declaration during name resolution.
186
    pub id: Option<DeclId>,
187
}
188

            
189
impl SortDecl {
190
    /// Creates a new sort declaration with the given identifier, expression, and span.
191
6013
    pub fn new(identifier: String, expr: Option<SortExpression>, span: Span) -> Self {
192
6013
        SortDecl {
193
6013
            identifier,
194
6013
            expr,
195
6013
            span,
196
6013
            id: None,
197
6013
        }
198
6013
    }
199
}
200

            
201
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
202
pub struct EqnSpec {
203
    pub variables: Vec<IdDecl>,
204
    pub equations: Vec<EqnDecl>,
205
}
206

            
207
/// Equation declaration
208
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
209
pub struct EqnDecl {
210
    pub condition: Option<DataExpr>,
211
    pub lhs: DataExpr,
212
    pub rhs: DataExpr,
213
    pub span: Span,
214
}
215

            
216
/// Action declaration
217
#[derive(Debug, Eq, PartialEq, Hash)]
218
pub struct ActDecl {
219
    pub identifier: String,
220
    pub args: Vec<SortExpression>,
221
    pub span: Span,
222
}
223

            
224
/// Process declaration
225
#[derive(Debug, Eq, PartialEq, Hash)]
226
pub struct ProcDecl {
227
    pub identifier: String,
228
    pub params: Vec<IdDecl>,
229
    pub body: ProcessExpr,
230
    pub span: Span,
231
}
232

            
233
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
234
pub enum DataExprUnaryOp {
235
    Negation,
236
    Minus,
237
    Size,
238
}
239

            
240
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
241
pub enum DataExprBinaryOp {
242
    Conj,
243
    Disj,
244
    Implies,
245
    Equal,
246
    NotEqual,
247
    LessThan,
248
    LessEqual,
249
    GreaterThan,
250
    GreaterEqual,
251
    Cons,
252
    Snoc,
253
    In,
254
    Concat,
255
    Add,
256
    Subtract,
257
    Div,
258
    IntDiv,
259
    Mod,
260
    Multiply,
261
    At,
262
}
263

            
264
/// Data expression
265
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
266
pub enum DataExpr {
267
    Id(String),
268
    Number(String), // Is string because the number can be any size.
269
    Bool(bool),
270
    Application {
271
        function: Box<DataExpr>,
272
        arguments: Vec<DataExpr>,
273
    },
274
    EmptyList,
275
    List(Vec<DataExpr>),
276
    EmptySet,
277
    Set(Vec<DataExpr>),
278
    EmptyBag,
279
    Bag(Vec<BagElement>),
280
    SetBagComp {
281
        variable: IdDecl,
282
        predicate: Box<DataExpr>,
283
    },
284
    Lambda {
285
        variables: Vec<IdDecl>,
286
        body: Box<DataExpr>,
287
    },
288
    Quantifier {
289
        op: Quantifier,
290
        variables: Vec<IdDecl>,
291
        body: Box<DataExpr>,
292
    },
293
    Unary {
294
        op: DataExprUnaryOp,
295
        expr: Box<DataExpr>,
296
    },
297
    Binary {
298
        op: DataExprBinaryOp,
299
        lhs: Box<DataExpr>,
300
        rhs: Box<DataExpr>,
301
    },
302
    FunctionUpdate {
303
        expr: Box<DataExpr>,
304
        update: Box<DataExprUpdate>,
305
    },
306
    Whr {
307
        expr: Box<DataExpr>,
308
        assignments: Vec<Assignment>,
309
    },
310
}
311

            
312
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
313
pub struct BagElement {
314
    pub expr: DataExpr,
315
    pub multiplicity: DataExpr,
316
}
317

            
318
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
319
pub struct DataExprUpdate {
320
    pub expr: DataExpr,
321
    pub update: DataExpr,
322
}
323

            
324
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
325
pub struct Assignment {
326
    pub identifier: String,
327
    pub expr: DataExpr,
328
}
329

            
330
#[derive(Debug, Eq, PartialEq, Hash)]
331
pub enum ProcExprBinaryOp {
332
    Sequence,
333
    Choice,
334
    Parallel,
335
    LeftMerge,
336
    CommMerge,
337
}
338

            
339
/// Process expression
340
#[derive(Debug, Eq, PartialEq, Hash)]
341
pub enum ProcessExpr {
342
    Id(String, Vec<Assignment>),
343
    Action(String, Vec<DataExpr>),
344
    Delta,
345
    Tau,
346
    Sum {
347
        variables: Vec<IdDecl>,
348
        operand: Box<ProcessExpr>,
349
    },
350
    Dist {
351
        variables: Vec<IdDecl>,
352
        expr: DataExpr,
353
        operand: Box<ProcessExpr>,
354
    },
355
    Binary {
356
        op: ProcExprBinaryOp,
357
        lhs: Box<ProcessExpr>,
358
        rhs: Box<ProcessExpr>,
359
    },
360
    Hide {
361
        actions: Vec<String>,
362
        operand: Box<ProcessExpr>,
363
    },
364
    Rename {
365
        renames: Vec<Rename>,
366
        operand: Box<ProcessExpr>,
367
    },
368
    Allow {
369
        actions: Vec<MultiActionLabel>,
370
        operand: Box<ProcessExpr>,
371
    },
372
    Block {
373
        actions: Vec<String>,
374
        operand: Box<ProcessExpr>,
375
    },
376
    Comm {
377
        comm: Vec<CommExpr>,
378
        operand: Box<ProcessExpr>,
379
    },
380
    Condition {
381
        condition: DataExpr,
382
        then: Box<ProcessExpr>,
383
        else_: Option<Box<ProcessExpr>>,
384
    },
385
    At {
386
        expr: Box<ProcessExpr>,
387
        operand: DataExpr,
388
    },
389
}
390

            
391
#[derive(Debug, Eq, PartialEq, Hash)]
392
pub struct UntypedStateFrmSpec {
393
    pub data_specification: UntypedDataSpecification,
394
    pub action_declarations: Vec<ActDecl>,
395
    pub formula: StateFrm,
396
}
397

            
398
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
399
pub enum StateFrmUnaryOp {
400
    Minus,
401
    Negation,
402
}
403

            
404
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
405
pub enum StateFrmOp {
406
    Addition,
407
    Implies,
408
    Disjunction,
409
    Conjunction,
410
}
411

            
412
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
413
pub enum FixedPointOperator {
414
    Least,
415
    Greatest,
416
}
417

            
418
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
419
pub struct StateVarDecl {
420
    pub identifier: String,
421
    pub arguments: Vec<StateVarAssignment>,
422
    pub span: Span,
423
}
424

            
425
impl StateVarDecl {
426
    /// Creates a new state variable declaration.
427
20104
    pub fn new(identifier: String, arguments: Vec<StateVarAssignment>) -> Self {
428
20104
        StateVarDecl {
429
20104
            identifier,
430
20104
            arguments,
431
20104
            span: Span::default(),
432
20104
        }
433
20104
    }
434
}
435

            
436
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
437
pub struct StateVarAssignment {
438
    pub identifier: String,
439
    pub sort: SortExpression,
440
    pub expr: DataExpr,
441
}
442

            
443
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
444
pub enum ModalityOperator {
445
    Diamond,
446
    Box,
447
}
448

            
449
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
450
pub enum StateFrm {
451
    True,
452
    False,
453
    Delay(DataExpr),
454
    Yaled(DataExpr),
455
    Id(String, Vec<DataExpr>),
456
    DataValExprLeftMult(DataExpr, Box<StateFrm>),
457
    DataValExprRightMult(Box<StateFrm>, DataExpr),
458
    DataValExpr(DataExpr),
459
    Modality {
460
        operator: ModalityOperator,
461
        formula: RegFrm,
462
        expr: Box<StateFrm>,
463
    },
464
    Unary {
465
        op: StateFrmUnaryOp,
466
        expr: Box<StateFrm>,
467
    },
468
    Binary {
469
        op: StateFrmOp,
470
        lhs: Box<StateFrm>,
471
        rhs: Box<StateFrm>,
472
    },
473
    Quantifier {
474
        quantifier: Quantifier,
475
        variables: Vec<IdDecl>,
476
        body: Box<StateFrm>,
477
    },
478
    Bound {
479
        bound: Bound,
480
        variables: Vec<IdDecl>,
481
        body: Box<StateFrm>,
482
    },
483
    FixedPoint {
484
        operator: FixedPointOperator,
485
        variable: StateVarDecl,
486
        body: Box<StateFrm>,
487
    },
488
}
489

            
490
/// Represents a multi action label `a | b | c ...`.
491
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
492
pub struct MultiActionLabel {
493
    pub actions: Vec<String>,
494
}
495

            
496
impl MultiActionLabel {
497
    /// Creates a new multi-action label from a list of action identifiers.
498
    pub fn new(actions: Vec<String>) -> Self {
499
        MultiActionLabel { actions }
500
    }
501

            
502
    /// Returns true if the multi-action label is empty (i.e., contains no actions).
503
    pub fn is_tau_label(&self) -> bool {
504
        self.actions.is_empty()
505
    }
506
}
507

            
508
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
509
pub struct Action {
510
    pub id: String,
511
    pub args: Vec<DataExpr>,
512
}
513

            
514
impl Action {
515
    /// Creates a new action from an identifier and a list of arguments.
516
7399
    pub fn new(id: String, args: Vec<DataExpr>) -> Self {
517
7399
        Action { id, args }
518
7399
    }
519
}
520

            
521
#[derive(Clone, Debug, Eq)]
522
pub struct MultiAction {
523
    pub actions: Vec<Action>,
524
}
525

            
526
impl MultiAction {
527
    /// Creates a new multi-action from a list of actions.
528
7399
    pub fn new(actions: Vec<Action>) -> Self {
529
7399
        MultiAction { actions }
530
7399
    }
531

            
532
    /// Creates the empty multi-action, which represents the tau action.
533
14273
    pub fn tau() -> Self {
534
14273
        MultiAction { actions: Vec::new() }
535
14273
    }
536
}
537

            
538
impl PartialEq for MultiAction {
539
58548
    fn eq(&self, other: &Self) -> bool {
540
        // Check whether both multi-actions contain the same actions
541
58548
        if self.actions.len() != other.actions.len() {
542
14868
            return false;
543
43680
        }
544

            
545
        // Map every action onto the other, equal length means they must be the same.
546
43680
        for action in self.actions.iter() {
547
22078
            if !other.actions.contains(action) {
548
7245
                return false;
549
14833
            }
550
        }
551

            
552
36435
        true
553
58548
    }
554
}
555

            
556
impl Hash for MultiAction {
557
24907
    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
558
24907
        let mut actions = self.actions.clone();
559
        // Sort the action ids to ensure that the hash is independent of the order.
560
24907
        actions.sort();
561
24907
        for action in actions {
562
10857
            action.hash(state);
563
10857
        }
564
24907
    }
565
}
566

            
567
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
568
pub enum Quantifier {
569
    Exists,
570
    Forall,
571
}
572

            
573
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
574
pub enum ActFrmBinaryOp {
575
    Implies,
576
    Union,
577
    Intersect,
578
}
579

            
580
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
581
pub enum ActFrm {
582
    True,
583
    False,
584
    MultAct(MultiAction),
585
    DataExprVal(DataExpr),
586
    Negation(Box<ActFrm>),
587
    Quantifier {
588
        quantifier: Quantifier,
589
        variables: Vec<IdDecl>,
590
        body: Box<ActFrm>,
591
    },
592
    Binary {
593
        op: ActFrmBinaryOp,
594
        lhs: Box<ActFrm>,
595
        rhs: Box<ActFrm>,
596
    },
597
}
598

            
599
#[derive(Debug, Eq, PartialEq, Hash)]
600
pub enum PbesExpr {
601
    DataValExpr(DataExpr),
602
    PropVarInst(PropVarInst),
603
    Quantifier {
604
        quantifier: Quantifier,
605
        variables: Vec<IdDecl>,
606
        body: Box<PbesExpr>,
607
    },
608
    Negation(Box<PbesExpr>),
609
    Binary {
610
        op: PbesExprBinaryOp,
611
        lhs: Box<PbesExpr>,
612
        rhs: Box<PbesExpr>,
613
    },
614
    True,
615
    False,
616
}
617

            
618
#[derive(Debug, Eq, PartialEq, Hash)]
619
pub enum Eq {
620
    EqInf,
621
    EqnInf,
622
}
623

            
624
#[derive(Debug, Eq, PartialEq, Hash)]
625
pub enum Condition {
626
    Condsm,
627
    Condeq,
628
}
629

            
630
// TODO: What should this be called?
631
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
632
pub enum Bound {
633
    Inf,
634
    Sup,
635
    Sum,
636
}
637

            
638
#[derive(Debug, Eq, PartialEq, Hash)]
639
pub enum PresExprBinaryOp {
640
    Implies,
641
    Disjunction,
642
    Conjunction,
643
    Add,
644
}
645

            
646
#[derive(Debug, Eq, PartialEq, Hash)]
647
pub enum PresExpr {
648
    DataValExpr(DataExpr),
649
    PropVarInst(PropVarInst),
650
    RightConstantMultiply {
651
        expr: Box<PresExpr>,
652
        constant: DataExpr,
653
    },
654
    LeftConstantMultiply {
655
        constant: DataExpr,
656
        expr: Box<PresExpr>,
657
    },
658
    Bound {
659
        op: Bound,
660
        variables: Vec<IdDecl>,
661
        expr: Box<PresExpr>,
662
    },
663
    Equal {
664
        eq: Eq,
665
        body: Box<PresExpr>,
666
    },
667
    Condition {
668
        condition: Condition,
669
        lhs: Box<PresExpr>,
670
        then: Box<PresExpr>,
671
        else_: Box<PresExpr>,
672
    },
673
    Negation(Box<PresExpr>),
674
    Binary {
675
        op: PresExprBinaryOp,
676
        lhs: Box<PresExpr>,
677
        rhs: Box<PresExpr>,
678
    },
679
    True,
680
    False,
681
}
682

            
683
#[derive(Debug, Eq, PartialEq, Hash)]
684
pub struct PbesEquation {
685
    pub operator: FixedPointOperator,
686
    pub variable: PropVarDecl,
687
    pub formula: PbesExpr,
688
    pub span: Span,
689
}
690

            
691
impl PbesEquation {
692
    /// Creates a new PBES equation with the given operator, variable and formula.
693
    pub fn new(operator: FixedPointOperator, variable: PropVarDecl, formula: PbesExpr) -> Self {
694
        PbesEquation {
695
            operator,
696
            variable,
697
            formula,
698
            span: Span::default(),
699
        }
700
    }
701
}
702

            
703
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
704
pub enum PbesExprBinaryOp {
705
    Implies,
706
    Disjunction,
707
    Conjunction,
708
}
709

            
710
#[derive(Debug, Eq, PartialEq, Hash)]
711
pub struct PresEquation {
712
    pub operator: FixedPointOperator,
713
    pub variable: PropVarDecl,
714
    pub formula: PresExpr,
715
    pub span: Span,
716
}
717

            
718
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
719
pub enum RegFrm {
720
    Action(ActFrm),
721
    Iteration(Box<RegFrm>),
722
    Plus(Box<RegFrm>),
723
    Sequence { lhs: Box<RegFrm>, rhs: Box<RegFrm> },
724
    Choice { lhs: Box<RegFrm>, rhs: Box<RegFrm> },
725
}
726

            
727
#[derive(Debug, Eq, PartialEq, Hash)]
728
pub struct Rename {
729
    pub from: String,
730
    pub to: String,
731
}
732

            
733
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
734
pub struct CommExpr {
735
    pub from: MultiActionLabel,
736
    pub to: String,
737
}
738

            
739
impl CommExpr {
740
    /// Creates a new communication expression from a multi-action label and a target action identifier.
741
    pub fn new(from: MultiActionLabel, to: String) -> Self {
742
        CommExpr { from, to }
743
    }
744
}
745

            
746
#[derive(Debug, Eq, PartialEq, Hash)]
747
pub struct UntypedActionRenameSpec {
748
    pub data_specification: UntypedDataSpecification,
749
    pub action_declarations: Vec<ActDecl>,
750
    pub rename_declarations: Vec<ActionRenameDecl>,
751
}
752

            
753
#[derive(Debug, Eq, PartialEq, Hash)]
754
pub struct ActionRenameDecl {
755
    pub variables_specification: Vec<IdDecl>,
756
    pub rename_rule: ActionRenameRule,
757
}
758

            
759
#[derive(Debug, Eq, PartialEq, Hash)]
760
pub struct ActionRenameRule {
761
    pub condition: Option<DataExpr>,
762
    pub action: Action,
763
    pub rhs: ActionRHS,
764
}
765

            
766
#[derive(Debug, Eq, PartialEq, Hash)]
767
pub enum ActionRHS {
768
    Tau,
769
    Delta,
770
    Action(Action),
771
}
772

            
773
/// Source location information, spanning from start to end in the source text.
774
#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
775
pub struct Span {
776
    pub start: usize,
777
    pub end: usize,
778
}
779

            
780
impl From<pest::Span<'_>> for Span {
781
203891
    fn from(span: pest::Span) -> Self {
782
203891
        Span {
783
203891
            start: span.start(),
784
203891
            end: span.end(),
785
203891
        }
786
203891
    }
787
}