Fix lexer to properly cope with repeated comments
This PR fixes a bug in the lexer that treated repeated comments as parse errors even if `ignore_comment` was set to true.

Closes #2330.
{"label": "nlohmann:develop", "ref": "develop", "sha": "1da931730a73365a5a817c8571d36c9ef024dd57"}
<!-- Provide a concise summary of the issue in the title above. -->
I know comments are not supported in json, but I'm trying to migrate a project that used YAJL, which has an option for allowing comments, specifically multiple consecutive lines of comments:

// description
// more description
{
...
}

I'm using the parse(...,ignore_comments=true) option, but it's failing on the second comment line. I


#### What is the issue you have?

<!-- Provide a detailed introduction to the issue itself, and why you consider it to be a bug. -->
<!-- If possible, be specific and add stack traces, error messages, etc. Avoid vague terms like "crash" or "doesn't work". -->

#### Please describe the steps to reproduce the issue.
std::string ss = "//\n//\n{\n}\n";
json j = json::parse(ss,nullptr,true,true);

#### Can you provide a small but working code example?

std::string ss = "//\n//\n{\n}\n";
json j = json::parse(ss,nullptr,true,true);

#### What is the expected behavior?

should ignore both lines

#### And what is the actual behavior instead?
terminate called after throwing an instance of 'nlohmann::detail::parse_error'
  what():  [json.exception.parse_error.101] parse error at line 2, column 1: syntax error while parsing value - invalid literal; last read: '//<U+000A>/'
Aborted (core dumped)


#### Which compiler and operating system are you using?
- Compiler: gcc 9.2
- Operating system: Ubuntu 20.04

#### Which version of the library did you use?

<!-- Please add an `x` to the respective line. -->

- [ ] latest release version 3.9.0
- [ ] other release - please state the version: ___
- [x ] the `develop` branch (35daa5c0)

#### If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)?

- [x ] yes
- [ ] no - please copy/paste the error message below

ignore_comment=true fails on multiple consecutive lines starting with comments
diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp
index 60eb3526f0..b255b9d200 100644
--- a/include/nlohmann/detail/input/lexer.hpp
+++ b/include/nlohmann/detail/input/lexer.hpp
@@ -1511,7 +1511,7 @@ class lexer : public lexer_base<BasicJsonType>
         skip_whitespace();
 
         // ignore comments
-        if (ignore_comments && current == '/')
+        while (ignore_comments && current == '/')
         {
             if (!scan_comment())
             {
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 9c66a8457f..723773ded7 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -7390,7 +7390,7 @@ class lexer : public lexer_base<BasicJsonType>
         skip_whitespace();
 
         // ignore comments
-        if (ignore_comments && current == '/')
+        while (ignore_comments && current == '/')
         {
             if (!scan_comment())
             {

diff --git a/test/src/unit-class_lexer.cpp b/test/src/unit-class_lexer.cpp
index 0f544d5553..6d4ede8a5e 100644
--- a/test/src/unit-class_lexer.cpp
+++ b/test/src/unit-class_lexer.cpp
@@ -241,5 +241,8 @@ TEST_CASE("lexer class")
         CHECK((scan_string("/* true */", true) == json::lexer::token_type::end_of_input));
         CHECK((scan_string("/*/**/", true) == json::lexer::token_type::end_of_input));
         CHECK((scan_string("/*/* */", true) == json::lexer::token_type::end_of_input));
+
+        CHECK((scan_string("//\n//\n", true) == json::lexer::token_type::end_of_input));
+        CHECK((scan_string("/**//**//**/", true) == json::lexer::token_type::end_of_input));
     }
 }
diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp
index d445f068e8..1f8c527de7 100644
--- a/test/src/unit-regression2.cpp
+++ b/test/src/unit-regression2.cpp
@@ -478,4 +478,11 @@ TEST_CASE("regression tests 2")
         CHECK(jsonObj["aaaa"] == 11);
         CHECK(jsonObj["bbb"] == 222);
     }
+
+    SECTION("issue #2330 - ignore_comment=true fails on multiple consecutive lines starting with comments")
+    {
+        std::string ss = "//\n//\n{\n}\n";
+        json j = json::parse(ss, nullptr, true, true);
+        CHECK(j.dump() == "{}");
+    }
 }

{"test-regression2": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "test-class_lexer": {"run": "PASS", "test": "NONE", "fix": "PASS"}}
{"test-noexcept": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-large_json": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-testsuites": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-convenience": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_fetch_content_build": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-reference_access": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-wstring": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_import_build": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-to_chars": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "download_test_data": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-ubjson": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_target_include_directories_configure": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-bson": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-allocator": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-ordered_json": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-element_access2": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_import_minver_build": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-cbor": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_import_minver_configure": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-ordered_map": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-capacity": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-udt": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-concepts": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-comparison": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-modifiers": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-user_defined_input": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_add_subdirectory_configure": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-unicode": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-class_iterator": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-constructor2": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-hash": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-readme": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_target_include_directories_build": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-iterators1": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-conversions": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-msgpack": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-iterators2": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-inspection": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-meta": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-items": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-constructor1": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-class_parser": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-json_patch": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_fetch_content_configure": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-element_access1": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-merge_patch": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-serialization": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-json_pointer": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-deserialization": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-assert_macro": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-pointer_access": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-alt-string": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-regression1": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_import_configure": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-algorithms": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-udt_macro": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test-class_const_iterator": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "cmake_add_subdirectory_build": {"run": "PASS", "test": "PASS", "fix": "PASS"}}
{"test-regression2": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "test-class_lexer": {"run": "PASS", "test": "NONE", "fix": "PASS"}}
{"passed_count": 60, "failed_count": 0, "skipped_count": 0, "passed_tests": ["test-noexcept", "test-udt_macro", "test-large_json", "test-testsuites", "test-convenience", "test-regression2", "cmake_fetch_content_build", "test-reference_access", "test-wstring", "cmake_import_build", "test-to_chars", "download_test_data", "test-ubjson", "cmake_target_include_directories_configure", "test-bson", "test-allocator", "test-ordered_json", "test-element_access2", "cmake_import_minver_build", "test-cbor", "cmake_import_minver_configure", "test-ordered_map", "test-capacity", "test-class_lexer", "test-udt", "test-concepts", "test-comparison", "test-class_const_iterator", "test-modifiers", "test-user_defined_input", "test-unicode", "test-class_iterator", "test-constructor2", "test-hash", "test-readme", "cmake_target_include_directories_build", "test-iterators1", "test-conversions", "test-msgpack", "test-iterators2", "test-inspection", "test-meta", "test-items", "test-constructor1", "test-json_patch", "cmake_fetch_content_configure", "test-element_access1", "test-merge_patch", "test-serialization", "test-json_pointer", "test-assert_macro", "test-pointer_access", "cmake_add_subdirectory_configure", "test-alt-string", "test-regression1", "cmake_import_configure", "test-algorithms", "test-class_parser", "test-deserialization", "cmake_add_subdirectory_build"], "failed_tests": [], "skipped_tests": []}
{"passed_count": 58, "failed_count": 0, "skipped_count": 0, "passed_tests": ["test-noexcept", "test-udt_macro", "test-large_json", "test-testsuites", "test-convenience", "cmake_fetch_content_build", "test-reference_access", "test-wstring", "cmake_import_build", "test-to_chars", "download_test_data", "test-ubjson", "cmake_target_include_directories_configure", "test-bson", "test-allocator", "test-ordered_json", "test-element_access2", "cmake_import_minver_build", "test-cbor", "cmake_import_minver_configure", "test-ordered_map", "test-capacity", "test-user_defined_input", "test-udt", "test-concepts", "test-comparison", "test-class_const_iterator", "test-modifiers", "cmake_add_subdirectory_configure", "test-unicode", "test-class_iterator", "test-constructor2", "test-hash", "test-readme", "cmake_target_include_directories_build", "test-iterators1", "test-conversions", "test-msgpack", "test-iterators2", "test-inspection", "test-meta", "test-items", "test-constructor1", "test-json_patch", "cmake_fetch_content_configure", "test-element_access1", "test-merge_patch", "test-serialization", "test-json_pointer", "test-assert_macro", "test-pointer_access", "test-alt-string", "test-regression1", "cmake_import_configure", "test-algorithms", "test-class_parser", "test-deserialization", "cmake_add_subdirectory_build"], "failed_tests": [], "skipped_tests": []}
{"passed_count": 60, "failed_count": 0, "skipped_count": 0, "passed_tests": ["test-noexcept", "test-udt_macro", "test-large_json", "test-testsuites", "test-convenience", "test-regression2", "cmake_fetch_content_build", "test-reference_access", "test-wstring", "cmake_import_build", "test-to_chars", "download_test_data", "test-ubjson", "cmake_target_include_directories_configure", "test-bson", "test-allocator", "test-ordered_json", "test-element_access2", "cmake_import_minver_build", "test-cbor", "cmake_import_minver_configure", "test-ordered_map", "test-capacity", "test-class_lexer", "test-udt", "test-concepts", "test-comparison", "test-class_const_iterator", "test-modifiers", "test-user_defined_input", "test-unicode", "test-class_iterator", "test-constructor2", "test-hash", "test-readme", "cmake_target_include_directories_build", "test-iterators1", "test-conversions", "test-msgpack", "test-iterators2", "test-inspection", "test-meta", "test-items", "test-constructor1", "test-json_patch", "cmake_fetch_content_configure", "test-element_access1", "test-merge_patch", "test-serialization", "test-json_pointer", "test-assert_macro", "test-pointer_access", "cmake_add_subdirectory_configure", "test-alt-string", "test-regression1", "cmake_import_configure", "test-algorithms", "test-class_parser", "test-deserialization", "cmake_add_subdirectory_build"], "failed_tests": [], "skipped_tests": []}