[lexer] Add fail() constructor to StateResult
This commit is contained in:
parent
d69c3dbc31
commit
7b6259977f
1 changed files with 6 additions and 0 deletions
|
@ -35,3 +35,9 @@ pub trait State: Debug {
|
||||||
fn lex(&mut self, c: char) -> StateResult;
|
fn lex(&mut self, c: char) -> StateResult;
|
||||||
fn none(&mut self) -> Result<Option<Token>, String>;
|
fn none(&mut self) -> Result<Option<Token>, String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl StateResult {
|
||||||
|
pub fn fail(msg: &str) -> StateResult {
|
||||||
|
StateResult::Fail { msg: msg.to_string() }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue