[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Wed May 1 11:01:33 PDT 2024
================
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+
+import argparse
+import re
+
+HEADER = """\
+//===-- SBLanguages.h -----------------------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBLANGUAGE_H
+#define LLDB_API_SBLANGUAGE_H
+/// Used by \\ref SBExpressionOptions.
+/// These enumerations use the same language enumerations as the DWARF
+/// specification for ease of use and consistency.
+enum SBSourceLanguageName : uint16_t {
+"""
+
+FOOTER = """\
+};
+
+#endif
+"""
+
+REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*')
+
+
+def emit_enum(input, output):
+ # Read the input and break it up by lines.
+ lines = []
+ with open(input, "r") as f:
+ lines = f.readlines()
+
+ # Write the output.
+ with open(output, "w") as f:
+ # Emit the header.
+ f.write(HEADER)
+
+ # Emit the enum values.
+ for line in lines:
+ match = REGEX.search(line)
----------------
kastiglione wrote:
since the regex is anchored to the start (`^`), this should probably be match (in which case you can remove the `^` if you want)
https://github.com/llvm/llvm-project/pull/90753
More information about the lldb-commits
mailing list