From 2ce19d9fd8f75ee1e3d62762e91f5d18303d4d6b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 11 Jul 2022 19:49:34 +0200 Subject: Add support for lazy lines --- src/construct/code_indented.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/construct/code_indented.rs') diff --git a/src/construct/code_indented.rs b/src/construct/code_indented.rs index 8966249..74a0938 100644 --- a/src/construct/code_indented.rs +++ b/src/construct/code_indented.rs @@ -128,17 +128,20 @@ fn after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// cd /// ``` fn further_start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { - // To do: `nok` if lazy line. - match code { - Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { - tokenizer.enter(Token::LineEnding); - tokenizer.consume(code); - tokenizer.exit(Token::LineEnding); - (State::Fn(Box::new(further_start)), None) + if tokenizer.lazy { + (State::Nok, None) + } else { + match code { + Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { + tokenizer.enter(Token::LineEnding); + tokenizer.consume(code); + tokenizer.exit(Token::LineEnding); + (State::Fn(Box::new(further_start)), None) + } + _ => tokenizer.attempt(space_or_tab_min_max(TAB_SIZE, TAB_SIZE), |ok| { + Box::new(if ok { further_end } else { further_begin }) + })(tokenizer, code), } - _ => tokenizer.attempt(space_or_tab_min_max(TAB_SIZE, TAB_SIZE), |ok| { - Box::new(if ok { further_end } else { further_begin }) - })(tokenizer, code), } } -- cgit