From f9c25c1d2376c37d233f6272c84799f7ec4905aa Mon Sep 17 00:00:00 2001 From: ahmedsamyh Date: Sat, 16 Nov 2024 21:38:03 +0500 Subject: [PATCH] Left trim until non-whitespace. --- main.momo | 5 +++++ main.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/main.momo b/main.momo index 4cafbe0..794a03c 100644 --- a/main.momo +++ b/main.momo @@ -1 +1,6 @@ + + + + + "This is a long ass string" diff --git a/main.py b/main.py index 6267069..0a40e28 100644 --- a/main.py +++ b/main.py @@ -100,14 +100,24 @@ class Parser: return (string, string_loc) + def left_trim(self): + while self.current_char().isspace(): + self.consume_char() + # dlog(f"Skipping {self.current_char()}") + + # dlog(f"Char after left trim: '{self.current_char()}'") + def next_token(self) -> Token | None: + self.left_trim() + c = self.current_char() t: Token | None = None if c == '"': value, loc = self.consume_string() t = Token(TokenType.STRING, value, loc) - pass + else: + fatal(f"Unrecognized character '{c}'") return t def main(): -- 2.39.5