More examples, better defaults
grammar_separated is grammar but with all functions exposed
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
use std::cmp;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::rc::Rc;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -256,9 +257,9 @@ where
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, Hash)]
|
||||
pub struct Environment {
|
||||
definitions: HashMap<IdType, Process>,
|
||||
definitions: BTreeMap<IdType, Process>,
|
||||
}
|
||||
|
||||
impl BasicEnvironment for Environment {
|
||||
@ -411,7 +412,7 @@ impl PrintableWithTranslator for Environment {
|
||||
|
||||
impl IntoIterator for Environment {
|
||||
type Item = (IdType, Process);
|
||||
type IntoIter = std::collections::hash_map::IntoIter<IdType, Process>;
|
||||
type IntoIter = std::collections::btree_map::IntoIter<IdType, Process>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.definitions.into_iter()
|
||||
@ -420,7 +421,7 @@ impl IntoIterator for Environment {
|
||||
|
||||
impl<'a> IntoIterator for &'a Environment {
|
||||
type Item = (&'a IdType, &'a Process);
|
||||
type IntoIter = std::collections::hash_map::Iter<'a, IdType, Process>;
|
||||
type IntoIter = std::collections::btree_map::Iter<'a, IdType, Process>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.definitions.iter()
|
||||
@ -430,7 +431,7 @@ impl<'a> IntoIterator for &'a Environment {
|
||||
impl<const N: usize> From<[(IdType, Process); N]> for Environment {
|
||||
fn from(arr: [(IdType, Process); N]) -> Self {
|
||||
Environment {
|
||||
definitions: HashMap::from(arr),
|
||||
definitions: BTreeMap::from(arr),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -438,7 +439,7 @@ impl<const N: usize> From<[(IdType, Process); N]> for Environment {
|
||||
impl From<&[(IdType, Process)]> for Environment {
|
||||
fn from(arr: &[(IdType, Process)]) -> Self {
|
||||
Environment {
|
||||
definitions: HashMap::from_iter(arr.to_vec()),
|
||||
definitions: BTreeMap::from_iter(arr.to_vec()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -446,11 +447,12 @@ impl From<&[(IdType, Process)]> for Environment {
|
||||
impl From<Vec<(IdType, Process)>> for Environment {
|
||||
fn from(arr: Vec<(IdType, Process)>) -> Self {
|
||||
Environment {
|
||||
definitions: HashMap::from_iter(arr),
|
||||
definitions: BTreeMap::from_iter(arr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Confluence
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@ -4,6 +4,7 @@ use std::rc::Rc;
|
||||
|
||||
use petgraph::visit::{IntoEdgeReferences, IntoNodeReferences};
|
||||
use petgraph::{Directed, Graph};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::element::IdType;
|
||||
use super::label::Label;
|
||||
@ -97,7 +98,7 @@ common_label!(
|
||||
// Nodes -----------------------------------------------------------------------
|
||||
|
||||
/// Helper structure that specifies what information to display for nodes.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub enum NodeDisplayBase {
|
||||
String { string: String },
|
||||
Hide,
|
||||
@ -109,6 +110,7 @@ pub enum NodeDisplayBase {
|
||||
MaskUncommonEntities { mask: Set },
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub struct NodeDisplay {
|
||||
pub base: Vec<NodeDisplayBase>,
|
||||
}
|
||||
@ -183,7 +185,7 @@ impl NodeDisplay {
|
||||
|
||||
// Edges -----------------------------------------------------------------------
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub enum EdgeDisplayBase {
|
||||
String {
|
||||
string: String,
|
||||
@ -219,6 +221,7 @@ pub enum EdgeDisplayBase {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub struct EdgeDisplay {
|
||||
pub base: Vec<EdgeDisplayBase>,
|
||||
}
|
||||
@ -481,7 +484,7 @@ type RSformatNodeTyOpt<'a> = dyn Fn(
|
||||
) -> Option<String>
|
||||
+ 'a;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Hash)]
|
||||
pub enum OperationType {
|
||||
Equals,
|
||||
Subset,
|
||||
@ -502,7 +505,7 @@ impl OperationType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub enum ContextColorConditional {
|
||||
Nill,
|
||||
RecursiveIdentifier(IdType),
|
||||
@ -512,13 +515,13 @@ pub enum ContextColorConditional {
|
||||
WaitEntity,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub enum NodeColorConditional {
|
||||
ContextConditional(ContextColorConditional),
|
||||
EntitiesConditional(OperationType, Set),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub struct NodeColor {
|
||||
pub conditionals: Vec<(NodeColorConditional, String)>,
|
||||
pub base_color: String,
|
||||
@ -620,7 +623,7 @@ type RSformatEdgeTyOpt<'a> = dyn Fn(
|
||||
) -> Option<String>
|
||||
+ 'a;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub enum EdgeColorConditional {
|
||||
Entities(OperationType, Set),
|
||||
Context(OperationType, Set),
|
||||
@ -632,7 +635,7 @@ pub enum EdgeColorConditional {
|
||||
Products(OperationType, Set),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
pub struct EdgeColor {
|
||||
pub conditionals: Vec<(EdgeColorConditional, String)>,
|
||||
pub base_color: String,
|
||||
|
||||
Reference in New Issue
Block a user