From 0d9c4611922535533746d1a86f10ef4e701c950e Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 11 Aug 2022 17:26:17 +0200 Subject: Refactor attempts to remove unneeded state name --- src/tokenizer.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/tokenizer.rs') 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. -- cgit