From 1d8eddc63f8d05a85829713dc10900ffc5c220e2 Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Thu, 8 Feb 2024 16:42:37 -0700 Subject: [PATCH] fix evil lexer bug (it was actually quite subtle unlike prev.) --- src/Rlp/Lex.x | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Rlp/Lex.x b/src/Rlp/Lex.x index 3c07c24..f5e7e34 100644 --- a/src/Rlp/Lex.x +++ b/src/Rlp/Lex.x @@ -335,16 +335,17 @@ doBol inp l = do i <- indentLevel -- traceM $ "i: " <> show i -- important that we pop the lex state lest we find our lexer diverging - popLexState case off of -- the line is aligned with the previous. it therefore belongs to the -- same list - EQ -> insertSemicolon + EQ -> popLexState *> insertSemicolon -- the line is indented further than the previous, so we assume it is a -- line continuation. ignore it and move on! - GT -> lexToken + GT -> popLexState *> lexToken -- the line is indented less than the previous, pop the layout stack and - -- insert a closing brace. + -- insert a closing brace. make VERY good note of the fact that we do not + -- pop the lex state! this means doBol is called until indentation is EQ + -- GT. so if multiple layouts are closed at once, this catches that. LT -> popLayout >> insertRBrace thenDo :: LexerAction a -> P b -> LexerAction a