ML2 times out in test, but not on my machine

The forum doesn’t allow me to add a link to github, but my code is in repository aShabat/codecrafters-interpreter-gleam.
Logs:

remote: [tester::#ML2] Running tests for Stage #ML2 (Scanning: Division operator & comments)
remote: [tester::#ML2] [test-1] Running test case: 1
remote: [tester::#ML2] [test-1] Writing contents to ./test.lox:
remote: [tester::#ML2] [test-1.lox] //Comment
remote: [tester::#ML2] [test-1] $ ./your_program.sh tokenize test.lox
remote: [your_program]    Compiled in 0.03s
remote: [your_program]     Running main.main
remote: [tester::#ML2] [test-1] timed out, test exceeded 10 seconds
remote: [tester::#ML2] [test-1] Test failed

Hey @aShabat, would you mind briefly explaining how your code handles comments?

I tried running it locally with //Comment, but it didn’t produce any output:

Hi @andy1li. It’s in file src/scanner lines 185-199. When I encounter slash two times in a row i go into comment mode until I encounter ‘\n’. In comment mode all symbols are just skipped.
The code should ignore comments, but it still should output EOF. For me it does

❯ cat test.lox
//Comment%
❯ ./your_program.sh tokenize test.lox
   Compiled in 0.01s
   Compiled in 0.01s
    Running main.main
EOF  null

When I encounter slash two times in a row i go into comment mode until I encounter ‘\n’.

Please note that the specific test case //Comment does not end with \n.

@andy1li, Thank you! Fixed

1 Like