orosmatthew / hydrogen-cpp

A hobby programming language 🔥

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Line counting is broken in multiline comments

MistrzPiotr opened this issue · 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

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();
                }
            }