From 6bff33af20dbca118739a3b01ae29a85d7252a1a Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Thu, 8 Apr 2021 23:33:09 +0200 Subject: [PATCH] Fix parsing comment at end of file --- lib/Minilisp.pm | 2 +- t/comments.t | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Minilisp.pm b/lib/Minilisp.pm index 63db6a6..463daa3 100644 --- a/lib/Minilisp.pm +++ b/lib/Minilisp.pm @@ -47,7 +47,7 @@ sub tokenize { while ($str) { - if ($str =~ s/^;.*\n//) + if ($str =~ s/^;.*(\n|$)//) { $debug->("Comment"); # Comment. do nothing diff --git a/t/comments.t b/t/comments.t index 77061f9..804cc3b 100644 --- a/t/comments.t +++ b/t/comments.t @@ -1,2 +1,6 @@ ;; This is a comment (expect "Comment does not influence code" t) +;; Another comment +(expect "Comment does not influence code pt.2" t) ;; Even after another expression +(expect "Comment does not influence code pt.3" t) +;; Last comment