aboutsummaryrefslogtreecommitdiffstats
path: root/src/tokenizer.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 17:26:17 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 17:26:17 +0200
commit0d9c4611922535533746d1a86f10ef4e701c950e (patch)
treedd776161db75ba264b67830635b736ca5dd5c314 /src/tokenizer.rs
parent90969231bfcdfcd09bae646abba17d832b633376 (diff)
downloadmarkdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.tar.gz
markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.tar.bz2
markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.zip
Refactor attempts to remove unneeded state name
Diffstat (limited to '')
-rw-r--r--src/tokenizer.rs19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index fdca6c5..0b51c48 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -15,7 +15,7 @@ use crate::constant::TAB_SIZE;
use crate::event::{Content, Event, Kind, Link, Name, Point, VOID_EVENTS};
use crate::parser::ParseState;
use crate::resolve::{call as call_resolve, Name as ResolveName};
-use crate::state::{call, Name as StateName, State};
+use crate::state::{call, State};
use crate::util::edit_map::EditMap;
/// Info used to tokenize the current container.
@@ -525,9 +525,9 @@ impl<'a> Tokenizer<'a> {
self.stack.truncate(previous.stack_len);
}
- /// Parse with `name` and its future states, to see if that results in
- /// [`State::Ok`][] or [`State::Nok`][], then revert in both cases.
- pub fn check(&mut self, name: StateName, ok: State, nok: State) -> State {
+ /// Stack an attempt, moving to `ok` on [`State::Ok`][] and `nok` on
+ /// [`State::Nok`][], reverting in both cases.
+ pub fn check(&mut self, ok: State, nok: State) {
// Always capture (and restore) when checking.
// No need to capture (and restore) when `nok` is `State::Nok`, because the
// parent attempt will do it.
@@ -539,14 +539,11 @@ impl<'a> Tokenizer<'a> {
ok,
nok,
});
-
- call(self, name)
}
- /// Parse with `name` and its future states, to see if that results in
- /// [`State::Ok`][] or [`State::Nok`][], revert in the case of
- /// `State::Nok`.
- pub fn attempt(&mut self, name: StateName, ok: State, nok: State) -> State {
+ /// Stack an attempt, moving to `ok` on [`State::Ok`][] and `nok` on
+ /// [`State::Nok`][], reverting in the latter case.
+ pub fn attempt(&mut self, ok: State, nok: State) {
// Always capture (and restore) when checking.
// No need to capture (and restore) when `nok` is `State::Nok`, because the
// parent attempt will do it.
@@ -562,8 +559,6 @@ impl<'a> Tokenizer<'a> {
ok,
nok,
});
-
- call(self, name)
}
/// Tokenize.