Struct peepmatic_automata::InsertionBuilder [−][src]
pub struct InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output, { /* fields omitted */ }
Expand description
A builder for a new entry in a transducer automata.
Implementations
Insert the next character of input for this entry, and the associated output that should be emitted along with it.
In general, you want to add all of your output on the very first next
call, and use Output::empty()
for all the
rest. This enables the most tail-sharing of suffixes, which leads to the
most compact automatas.
However, there are times when you cannot emit output yet, as it
depends on having moved throught he automata further. For example, with
peepmatic
we cannot bind something from an optimization’s left-hand
side’s pattern until after we know it exists, which only happens after
we’ve moved some distance through the automata.
Finish this insertion.
Failure to call this method before this InsertionBuilder
is dropped
means that the insertion is not committed in the builder, and future
calls to InsertionBuilder::next
will
panic!
Set the optional, custom data for the current state.
If you assign different state data to two otherwise-identical states within the same shared prefix during insertion, it is implementation defined which state and custom state data is kept.
For suffixes, assigning different state data to two otehrwise-identical states will result in the duplication of those states: they won’t get de-duplicated.
Get the current state’s optional, custom data, if any.
For shared prefixes, this may return state data that was assigned to an equivalent state that was added earlier in the build process.