diff options
| author | Martin Haug <mhaug@live.de> | 2022-01-02 00:46:19 +0100 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2022-01-02 00:46:19 +0100 |
| commit | 5f114e18eb76a1937941b2ea64842b908c9ad89e (patch) | |
| tree | 0541aa560b19e5805603fc06b3440f40db3d5fd1 /src/parse/tokens.rs | |
| parent | 289122e83c085668e56e52225c2dcfd9417d6262 (diff) | |
Added a test framework for incremental parsing
Fix several errors:
- Indented markup is now reparsed right
- All end group errors will now fail a reparse
- Rightmost errors will always fail a reparse
Diffstat (limited to 'src/parse/tokens.rs')
| -rw-r--r-- | src/parse/tokens.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs index 836e8cf1..3a0ad1ad 100644 --- a/src/parse/tokens.rs +++ b/src/parse/tokens.rs @@ -293,10 +293,8 @@ impl<'s> Tokens<'s> { } else { NodeKind::EnDash } - } else if self.s.check_or(true, char::is_whitespace) { - NodeKind::Minus } else { - NodeKind::Text('-'.into()) + NodeKind::Minus } } @@ -312,11 +310,7 @@ impl<'s> Tokens<'s> { None }; - if self.s.check_or(true, char::is_whitespace) { - NodeKind::EnumNumbering(number) - } else { - NodeKind::Text(self.s.eaten_from(start).into()) - } + NodeKind::EnumNumbering(number) } fn raw(&mut self) -> NodeKind { @@ -742,12 +736,12 @@ mod tests { fn test_tokenize_text() { // Test basic text. t!(Markup[" /"]: "hello" => Text("hello")); - t!(Markup[" /"]: "hello-world" => Text("hello"), Text("-"), Text("world")); + t!(Markup[" /"]: "hello-world" => Text("hello"), Minus, Text("world")); // Test code symbols in text. t!(Markup[" /"]: "a():\"b" => Text("a():\"b")); t!(Markup[" /"]: ";:,|/+" => Text(";:,|"), Text("/+")); - t!(Markup[" /"]: "=-a" => Text("="), Text("-"), Text("a")); + t!(Markup[" /"]: "=-a" => Text("="), Minus, Text("a")); t!(Markup[" "]: "#123" => Text("#"), Text("123")); // Test text ends. @@ -804,7 +798,7 @@ mod tests { t!(Markup["a1/"]: "- " => Minus, Space(0)); t!(Markup[" "]: "." => EnumNumbering(None)); t!(Markup[" "]: "1." => EnumNumbering(Some(1))); - t!(Markup[" "]: "1.a" => Text("1."), Text("a")); + t!(Markup[" "]: "1.a" => EnumNumbering(Some(1)), Text("a")); t!(Markup[" /"]: "a1." => Text("a1.")); } |
