diff --git a/src/mango/lexing/code_lexer.rs b/src/mango/lexing/code_lexer.rs index 05fd61ea..59134bda 100644 --- a/src/mango/lexing/code_lexer.rs +++ b/src/mango/lexing/code_lexer.rs @@ -178,12 +178,16 @@ impl SubLexer for CodeLexer { panic!("Do not know how to proceed with parsing") } EOF() => { - // TODO: also dedent and end statement here + if self.indent <= 0 { + return SubLexerResult::End; + } + // TODO: currently the EndStatement is only made if the file stops on an indented line let mut tokens = vec![Tokens::EndStatement(EndStatementToken::new_end_line())]; for _ in 0..self.indent { // This line is dedented, make end tokens. tokens.push(Tokens::EndBlock(EndBlockToken::new(true, false))); } + self.indent = 0; SubLexerResult::Result(tokens) } }; diff --git a/src/mango/token/collect/all.rs b/src/mango/token/collect/all.rs index 0dd44600..618cc741 100644 --- a/src/mango/token/collect/all.rs +++ b/src/mango/token/collect/all.rs @@ -55,6 +55,6 @@ mod tests { #[test] fn test_tokens_size() { - assert!(size_of::() < 32); + assert!(size_of::() < 32, size_of::()); } } diff --git a/src/mango/util/strslice/char_ops.rs b/src/mango/util/strslice/char_ops.rs index 054ba7f3..894994aa 100644 --- a/src/mango/util/strslice/char_ops.rs +++ b/src/mango/util/strslice/char_ops.rs @@ -18,12 +18,10 @@ impl<'a> CharOps for &'a str { impl CharOps for String { fn without_char(&self, strip: &char) -> String { - println!("String.without_char"); - (&self).without_char(strip) + self.chars().filter(|chr| chr != strip).collect() } fn char_len(&self) -> usize { - println!("String.char_len"); - (&self).char_len() + self.chars().count() } }