Struct parol::analysis::k_tuples::KTuples [−][src]
Expand description
A set type consisting of terminal strings (called k-tuples)
Tuple Fields
0: HashSet<KTuple>
Implementations
Creates a new object from a slice of KTuple objects.
use parol::{KTuple, KTuples, CompiledTerminal};
use parol::analysis::k_tuple::TerminalMappings;
{
let tuples1 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal::eps()], 1)], 1);
let tuples2 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal::eps()], 1)], 1);
let result = tuples1.k_concat(&tuples2, 1);
let expected = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal::eps()], 1)], 1);
assert_eq!(expected, result, "[ε] + [ε] = [ε]");
}
{
let tuples1 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1)], 1)], 1);
let tuples2 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal::eps()], 1)], 1);
let result = tuples1.k_concat(&tuples2, 1);
let expected = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1)], 1)], 1);
assert_eq!(expected, result, "[a] + [ε] = [a]");
}
{
let tuples1 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal::eps()], 1)], 1);
let tuples2 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1)], 1)], 1);
let result = tuples1.k_concat(&tuples2, 1);
let expected = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1)], 1)], 1);
assert_eq!(expected, result, "[ε] + [a] = [a]");
}
{
let tuples1 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1)], 1)], 1);
let tuples2 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(2)], 1)], 1);
let result = tuples1.k_concat(&tuples2, 1);
let expected = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1)], 1)], 1);
assert_eq!(expected, result, "1: [a] + [b] = [a]");
}
{
let tuples1 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1)], 2)], 2);
let tuples2 = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(2)], 2)], 2);
let result = tuples1.k_concat(&tuples2, 2);
let expected = KTuples::of(&vec![KTuple::of(vec![CompiledTerminal(1), CompiledTerminal(2)], 2)], 2);
assert_eq!(expected, result, "2: [a] + [b] = [ab]");
}
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for KTuples
impl UnwindSafe for KTuples
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.