Skip to content

Commit 83f3ca5

Browse files
committed
Move back to the Trie
The graph did work out for a very limited set of match expressions, but to handle them all you really need a NFA. So, admit to that and let word based opcodes be handled by the simple mechanism of a trie and only the complicated stuff by using a regexp engine
1 parent 6382c29 commit 83f3ca5

File tree

3 files changed

+7
-664
lines changed

3 files changed

+7
-664
lines changed

src/translator.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use std::collections::{HashMap, HashSet};
22

3-
use graph::Graph;
3+
use trie::Trie;
44

55
use crate::parser::{AnchoredRule, Attribute, Braille, Direction, Rule, dots_to_unicode, fallback};
66

7-
use self::graph::Boundary;
7+
use self::trie::Boundary;
88

99
mod boundaries;
10-
mod graph;
1110
mod match_pattern;
1211
mod nfa;
1312
mod trie;
@@ -163,7 +162,7 @@ pub struct TranslationTable {
163162
undefined: Option<String>,
164163
character_definitions: CharacterDefinition,
165164
character_attributes: CharacterAttributes,
166-
translations: Graph,
165+
translations: Trie,
167166
direction: Direction,
168167
}
169168

@@ -175,7 +174,7 @@ impl TranslationTable {
175174
let mut undefined = None;
176175
let mut character_definitions = CharacterDefinition::new();
177176
let mut character_attributes = CharacterAttributes::new();
178-
let mut translations = Graph::new();
177+
let mut translations = Trie::new();
179178

180179
let rules: Vec<AnchoredRule> = rules
181180
.into_iter()
@@ -364,7 +363,6 @@ impl TranslationTable {
364363
..
365364
} => {
366365
let dots = character_definitions.braille_to_unicode(dots, chars)?;
367-
translations.insert_match(chars.to_string(), dots, pre, post);
368366
}
369367

370368
_ => (),
@@ -714,6 +712,7 @@ mod tests {
714712
assert_eq!(display_table.translate(&table.translate("a a")), "A A");
715713
}
716714

715+
#[ignore = "not yet implemented"]
717716
#[test]
718717
fn match_test() {
719718
let rules = vec![
@@ -730,6 +729,7 @@ mod tests {
730729
assert_eq!(table.translate("afoob"), "⠁⠉⠂");
731730
}
732731

732+
#[ignore = "not yet implemented"]
733733
#[test]
734734
fn match_with_any_test() {
735735
let rules = vec![
@@ -747,6 +747,7 @@ mod tests {
747747
assert_eq!(table.translate("ffoob"), "⠄⠉⠂");
748748
}
749749

750+
#[ignore = "not yet implemented"]
750751
#[test]
751752
fn match_with_set_test() {
752753
let rules = vec![

0 commit comments

Comments
 (0)