================
@@ -0,0 +1,182 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "MarkdownParser.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang::doc::markdown {
+
+namespace {
+
+/// A forward cursor over the lines of the input. Owns no storage; it points
+/// into a caller-provided array of lines and tracks the current position.
+/// Block parsers consume lines through this cursor instead of juggling a raw
+/// index, which keeps the parsing helpers free of manual bookkeeping.
+class LineCursor {
+public:
+  explicit LineCursor(llvm::ArrayRef<llvm::StringRef> Lines) : Lines(Lines) {}
+
+  bool atEnd() const { return Pos >= Lines.size(); }
+
+  /// The current line, trimmed of surrounding whitespace.
+  llvm::StringRef peek() const { return Lines[Pos].trim(); }
+
+  /// The current line as it appears in the source, without trimming.
+  llvm::StringRef peekRaw() const { return Lines[Pos]; }
+
+  void advance() { ++Pos; }
+
+private:
+  llvm::ArrayRef<llvm::StringRef> Lines;
+  size_t Pos = 0;
+};
----------------
ilovepi wrote:

This feels like a wrapper over ArrayRef w/ a worse interface. ... why not just 
use the iterator interface from ArrayRef?

https://github.com/llvm/llvm-project/pull/208003
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to