Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in compiler when the last line is a comment without newline #7

Open
adamritter opened this issue Dec 14, 2024 · 1 comment
Open

Comments

@adamritter
Copy link

adamritter commented Dec 14, 2024

This program works:

@main = 3
//

(newline after the comment)

But this HVML program doesn't:

@main = 3
//

(no newline after comment, I can't embed non-newline inside the bug report unfortunately)

�[1m
PARSE_ERROR�[0m

  • expected:
  • detected:
    2 | //

�[4m�[0m
hvml: key not found: "main"
CallStack (from HasCallStack):
error, called at src/HVML/Type.hs:398:17 in HVM3-0.1.0.0-inplace-hvml:HVML.Type

@ellie-bee
Copy link

I haven't had the chance to test yet, but I believe this will solve this problem.

diff --git a/src/HVML/Parse.hs b/src/HVML/Parse.hs
index b53d4a6..b4891eb 100644
--- a/src/HVML/Parse.hs
+++ b/src/HVML/Parse.hs
@@ -441,7 +441,7 @@ skip = skipMany (parseSpace <|> parseComment) where
   parseComment = (try $ do
     string "//"
     skipMany (noneOf "\n")
-    char '\n'
+    (char '\n' <|> eof)
     return ()) <?> "Comment"

 genFreshLabel :: ParserM Word64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants