hydrogen-cpp icon indicating copy to clipboard operation
hydrogen-cpp copied to clipboard

Line counting is broken in multiline comments

Open PtrCz opened this issue 1 year ago • 1 comments

To show a very simple example:

  1. /*
  2. comment
  3. */
  4. let x = 0

Error message is "[Parse Error] Expected ; on line 2" even tho the error is on line 4

PtrCz avatar Feb 06 '24 16:02 PtrCz

In the tokenizer just continue to increment the line_count every time there's a new line.

else if (peek().value() == '\\') {
                consume();
                while (peek().has_value()) {
                    if (peek().value() == '\\') {
                        break;
                    }
                    if (peek().value() == '\n') {
                        line_count++;
                    }
                    consume();
                }
                if (peek().has_value()) {
                    consume();
                }
            }

vaelixd avatar Apr 21 '24 07:04 vaelixd