From 5f9524ebf61a987bf35eb577dbe0ff74441b04fd Mon Sep 17 00:00:00 2001 From: Henrik Wachowitz Date: Thu, 24 Jun 2021 15:38:43 +0200 Subject: [PATCH] fix issue with multiline comments --- whilelang/parse.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/whilelang/parse.py b/whilelang/parse.py index b96199c..015d02e 100644 --- a/whilelang/parse.py +++ b/whilelang/parse.py @@ -5,8 +5,15 @@ pad = regex(r'[^\S\r\n]') Newline = regex(r"\n") -Next = (Newline.at_least(1) - | eof).desc("at least one newline or the end of file") +_Next = (Newline.at_least(1) + | eof).desc("at least one newline or the end of file") + + +@generate +def Next(): + yield Comment | _Next >> Comment | _Next + + Comment = string("#") >> (regex(r'[\S]') | pad).many().concat() >> Next woc = whitespace << Comment.optional() << whitespace