erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.63k stars 54 forks source link

Comments cause errors to be misaligned #314

Open GreasySlug opened 1 year ago

GreasySlug commented 1 year ago

Describe the behavior

Currently comments are not included in tokens, though, they are there as characters in the actual code. Therefore, when an error occurs, the comment is not reflected and the error position is misaligned.

Reproducible code

#[]# a = 1

Expected behavior

rror[#0404]: File <stdin>, line 1, 

1 |   a = 1
  : --

SyntaxError: invalid indent

Current behavior

Error[#1447]: File .\tests\should_ok\comment.er, line 1, 

1 | #[]# print! "hi"
  : -

SyntaxError: invalid character: ' '

error: process didn't exit successfully: `target\debug\erg.exe .\tests\should_ok\comment.er` (exit cod

OS Windows 10