[Lldb-commits] [lldb] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). (PR #123521)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 5 00:46:46 PST 2025
================
@@ -0,0 +1,160 @@
+//===-- DILLexerTests.cpp --------------------------------------------===//
+//
+// 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 "lldb/ValueObject/DILLexer.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include <string>
+
+using llvm::StringRef;
+
+using namespace lldb_private::dil;
+
+llvm::Expected<std::vector<std::pair<Token::Kind, std::string>>>
+ExtractTokenData(llvm::StringRef input_expr) {
+
+ llvm::Expected<DILLexer> maybe_lexer = DILLexer::Create(input_expr);
+ if (!maybe_lexer)
+ return maybe_lexer.takeError();
+ DILLexer lexer(*maybe_lexer);
+
+ if (lexer.NumLexedTokens() == 0)
+ return llvm::createStringError("No lexed tokens");
+
+ lexer.ResetTokenIdx(0);
----------------
labath wrote:
I think this is unnecessary now.
https://github.com/llvm/llvm-project/pull/123521
More information about the lldb-commits
mailing list