Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
6fd5af1
qubit size adjustment
svenjeschmitt-ops Nov 3, 2025
8accf50
removing runtime error
svenjeschmitt-ops Nov 10, 2025
f4b0038
change classical varaible
svenjeschmitt-ops Nov 19, 2025
f7f27bd
new adjustments
svenjeschmitt-ops Nov 19, 2025
0cca5ca
adjustment
svenjeschmitt-ops Nov 19, 2025
a5c3eca
adjustment
svenjeschmitt-ops Nov 19, 2025
5222682
work and progress
svenjeschmitt-ops Nov 19, 2025
7e82180
work and progress
svenjeschmitt-ops Nov 19, 2025
e4155c4
amplitude adjustments
svenjeschmitt-ops Nov 24, 2025
64de683
License text
svenjeschmitt-ops Dec 1, 2025
732ca9b
:rocket: new files
svenjeschmitt-ops Dec 1, 2025
1e99c96
🎨 pre-commit fixes
pre-commit-ci[bot] Dec 1, 2025
88de5e5
docstrings
svenjeschmitt-ops Dec 2, 2025
057b5dd
_normalize_value updated
svenjeschmitt-ops Dec 2, 2025
1bed4cc
solving issue
svenjeschmitt-ops Dec 2, 2025
cc2c09b
solved DDSimDebug.cpp
svenjeschmitt-ops Dec 2, 2025
ad1fe09
next problem solved
svenjeschmitt-ops Dec 2, 2025
cd4dba9
last issue solved
svenjeschmitt-ops Dec 2, 2025
c3ca4b9
changement -Any-
svenjeschmitt-ops Dec 2, 2025
e43e740
last adjustment
svenjeschmitt-ops Dec 2, 2025
36fdd37
change_bit
svenjeschmitt-ops Dec 2, 2025
aa92b5f
DDSimDebug changement
svenjeschmitt-ops Dec 2, 2025
051fd1e
🎨 pre-commit fixes
pre-commit-ci[bot] Dec 2, 2025
261d3b0
first CI issue solved
svenjeschmitt-ops Dec 3, 2025
f6a5878
second issue solved
svenjeschmitt-ops Dec 3, 2025
8018667
last adjustments
svenjeschmitt-ops Dec 3, 2025
3dbd364
🎨 pre-commit fixes
pre-commit-ci[bot] Dec 3, 2025
2cd3395
fixed bug
svenjeschmitt-ops Dec 3, 2025
135fd94
adjustements
svenjeschmitt-ops Dec 3, 2025
b50cab1
adjustment checkorthrow
svenjeschmitt-ops Dec 3, 2025
bbc0cbb
Merge branch 'new_adjustments'
svenjeschmitt-ops Dec 3, 2025
ec901ce
linter issue
svenjeschmitt-ops Dec 3, 2025
1d1d848
Merge branch 'new_adjustments'
svenjeschmitt-ops Dec 3, 2025
ebe4cec
fix ci
svenjeschmitt-ops Dec 3, 2025
4b50146
fix lint
svenjeschmitt-ops Dec 3, 2025
465d447
🎨 pre-commit fixes
pre-commit-ci[bot] Dec 3, 2025
50da634
remove permissions workflow
svenjeschmitt-ops Dec 4, 2025
7398f50
non toggle function
svenjeschmitt-ops Dec 4, 2025
ea89e07
bool text adjusted
svenjeschmitt-ops Dec 4, 2025
5d3f383
function names
svenjeschmitt-ops Dec 4, 2025
e8e9f40
dotstrings
svenjeschmitt-ops Dec 4, 2025
ffe1a38
new version
svenjeschmitt-ops Dec 8, 2025
817e49e
github review changes
svenjeschmitt-ops Dec 8, 2025
c6b102f
fix linter
svenjeschmitt-ops Dec 8, 2025
1cefe3e
workflow file, not changed
svenjeschmitt-ops Dec 8, 2025
e10b1a0
highlight error
svenjeschmitt-ops Dec 8, 2025
ceaedcf
highlight error v2
svenjeschmitt-ops Dec 8, 2025
52ad47a
highlight error v3
svenjeschmitt-ops Dec 8, 2025
84c38f1
highlight error v4
svenjeschmitt-ops Dec 8, 2025
0d12f43
higlight error v4
svenjeschmitt-ops Dec 8, 2025
3ca8940
highlight_error
svenjeschmitt-ops Dec 9, 2025
543bd22
big fix
svenjeschmitt-ops Dec 9, 2025
9f13bd2
bug fix
svenjeschmitt-ops Dec 9, 2025
4ff44db
bug fix 2
svenjeschmitt-ops Dec 9, 2025
8e3b801
shows issue
svenjeschmitt-ops Dec 9, 2025
d1c343e
entire row
svenjeschmitt-ops Dec 9, 2025
59680cb
bug fix
svenjeschmitt-ops Dec 9, 2025
5532817
fix bug
svenjeschmitt-ops Dec 10, 2025
b6e4152
linter fix
svenjeschmitt-ops Dec 10, 2025
ac21598
Merge remote-tracking branch 'upstream/main'
svenjeschmitt-ops Dec 13, 2025
3e02a97
work and progress
svenjeschmitt-ops Dec 13, 2025
a7b5ce1
work and progress
svenjeschmitt-ops Dec 13, 2025
c8b03ee
work and progress
svenjeschmitt-ops Dec 13, 2025
59af8a0
Merge branch 'main' into highlight_error
svenjeschmitt-ops Dec 13, 2025
687bc9b
Merge remote-tracking branch 'upstream/main'
svenjeschmitt-ops Dec 16, 2025
ddc8b45
adjusted dotstrings
svenjeschmitt-ops Dec 16, 2025
4e67409
adjusted test_data_retrieval
svenjeschmitt-ops Dec 16, 2025
7308dab
adjusted test_python_bindings
svenjeschmitt-ops Dec 16, 2025
42a4bcf
🎨 pre-commit fixes
pre-commit-ci[bot] Dec 16, 2025
86cc5c9
work and progress
svenjeschmitt-ops Dec 16, 2025
5160144
adjusted test_data_retrieval
svenjeschmitt-ops Dec 16, 2025
7e0c3df
Merge remote-tracking branch 'origin/main' into highlight_error
svenjeschmitt-ops Dec 18, 2025
68a8ffe
highlight issue
svenjeschmitt-ops Dec 18, 2025
a7c6b72
assertion issue solved
svenjeschmitt-ops Dec 18, 2025
8ef979f
assertation issue solved
svenjeschmitt-ops Dec 18, 2025
83e928a
Merge branch 'main' into highlight_error
svenjeschmitt-ops Dec 18, 2025
47edfc0
highlight issue fix bug
svenjeschmitt-ops Dec 22, 2025
7b8fa09
🎨 pre-commit fixes
pre-commit-ci[bot] Dec 23, 2025
ec64afd
⬆️👨‍💻 Update actions/attest-build-provenance action to v3.1.0 (#234)
renovate[bot] Dec 20, 2025
32d14d8
⬆️🔒️ Lock file maintenance (#236)
renovate[bot] Dec 22, 2025
b734fc1
Merge remote-tracking branch 'upstream/main'
svenjeschmitt-ops Dec 24, 2025
92f4b4b
Revert "Merge branch 'main' into highlight_error"
svenjeschmitt-ops Dec 24, 2025
81801fa
Merge remote-tracking branch 'upstream'
svenjeschmitt-ops Dec 30, 2025
e151e5d
cc fix
svenjeschmitt-ops Dec 30, 2025
d5cd2e7
cc fix 2
svenjeschmitt-ops Dec 30, 2025
ff0e4b3
cc fix 3
svenjeschmitt-ops Dec 30, 2025
f2d9c9d
cc fix 4
svenjeschmitt-ops Dec 30, 2025
8d6d7f0
cc fix 5
svenjeschmitt-ops Dec 30, 2025
fbb9bd1
cc fix 6
svenjeschmitt-ops Dec 30, 2025
3653c60
more docstrings
svenjeschmitt-ops Dec 31, 2025
4bb141e
adjustemnts - coderabbit
svenjeschmitt-ops Jan 10, 2026
62ea2cc
solution without STDERR
svenjeschmitt-ops Jan 10, 2026
9563c25
adjustments ddSimAll
svenjeschmitt-ops Jan 10, 2026
4c34277
removed unused methods
svenjeschmitt-ops Jan 10, 2026
ccfd5bb
docstring CodePreprocessing
svenjeschmitt-ops Jan 10, 2026
8663fbe
merge newest version
svenjeschmitt-ops Jan 11, 2026
c256690
🎨 pre-commit fixes
pre-commit-ci[bot] Jan 11, 2026
cf270eb
launch,restart, LoadResult
svenjeschmitt-ops Jan 11, 2026
489592b
Revert "launch,restart, LoadResult"
svenjeschmitt-ops Jan 11, 2026
4de1403
fix launch and restart
svenjeschmitt-ops Jan 11, 2026
29607af
Revert "qubit size adjustment"
svenjeschmitt-ops Jan 11, 2026
5a7413f
_end_before_start
svenjeschmitt-ops Jan 11, 2026
9d98879
enum implemented
svenjeschmitt-ops Jan 11, 2026
a8c25e2
Reapply "qubit size adjustment"
svenjeschmitt-ops Jan 11, 2026
15bb5d9
LoadResult
svenjeschmitt-ops Jan 11, 2026
175bb08
Revert "LoadResult"
svenjeschmitt-ops Jan 11, 2026
f53a848
adjustments LoadResult
svenjeschmitt-ops Jan 14, 2026
d406d13
fix cl
svenjeschmitt-ops Jan 14, 2026
65f230c
adjustments
svenjeschmitt-ops Jan 14, 2026
55ad6b9
Merge remote-tracking branch 'upstream'
svenjeschmitt-ops Jan 14, 2026
3169e22
cl bug fix
svenjeschmitt-ops Jan 14, 2026
090de19
🎨 pre-commit fixes
pre-commit-ci[bot] Jan 14, 2026
c6faa23
fix but
svenjeschmitt-ops Jan 14, 2026
b2c0b2b
Merge remote-tracking branch 'upstream/main'
svenjeschmitt-ops Jan 15, 2026
6b15941
assortation fix + classical issue
svenjeschmitt-ops Jan 15, 2026
6fec6a9
pre- commit fix
svenjeschmitt-ops Jan 15, 2026
af49c19
♻️ Replace `pybind11` with `nanobind` (#248)
denialhaag Jan 15, 2026
03920d7
fix issue
svenjeschmitt-ops Jan 15, 2026
efbcd5c
Cl issue fix
svenjeschmitt-ops Jan 15, 2026
160c294
Code rabbit issue
svenjeschmitt-ops Jan 15, 2026
70897c1
Cl fix bug
svenjeschmitt-ops Jan 15, 2026
4695b89
Cl fix bug 2
svenjeschmitt-ops Jan 15, 2026
7e40ed9
Merge remote-tracking branch 'upstream'
svenjeschmitt-ops Jan 19, 2026
9349194
fix loadResult
svenjeschmitt-ops Jan 21, 2026
2f77e27
categorizing different errors
svenjeschmitt-ops Jan 21, 2026
6b9c1d7
improvement doctring and cleaner version
svenjeschmitt-ops Jan 21, 2026
c1eaccd
improvement launch dap
svenjeschmitt-ops Jan 21, 2026
fa522a6
fix Cl
svenjeschmitt-ops Jan 21, 2026
1f5e0ca
cl fix 2
svenjeschmitt-ops Jan 21, 2026
0e6bfa8
cl fix 3
svenjeschmitt-ops Jan 21, 2026
09f5ace
cl fix 4
svenjeschmitt-ops Jan 21, 2026
4f3e00d
remove file
svenjeschmitt-ops Jan 21, 2026
f2d905c
fix cl
svenjeschmitt-ops Jan 22, 2026
819d0f4
remove destroyDDSimulationState
svenjeschmitt-ops Jan 22, 2026
a70891c
Merge remote-tracking branch 'upstream/main'
svenjeschmitt-ops Jan 22, 2026
dd89f76
fix pre-commit
svenjeschmitt-ops Jan 22, 2026
5822fbd
cl fix 5
svenjeschmitt-ops Jan 22, 2026
adecd22
fix codecov
svenjeschmitt-ops Jan 22, 2026
0f9fd53
avoid boolean positional arg in locale.getpreferredencoding
svenjeschmitt-ops Jan 22, 2026
50abd27
pre-commit fix
svenjeschmitt-ops Jan 22, 2026
8e20311
Revert "fix pre-commit"
svenjeschmitt-ops Jan 22, 2026
5b5037e
fresh merge
svenjeschmitt-ops Feb 10, 2026
526da85
adjustments LOAD_OK and ASSERT_EQ
svenjeschmitt-ops Feb 10, 2026
13731ab
implemented doctring
svenjeschmitt-ops Feb 10, 2026
1cf068f
more specific exception catching
svenjeschmitt-ops Feb 10, 2026
a3d385e
remove if
svenjeschmitt-ops Feb 10, 2026
4283c11
parsing related materials to CodePreprocessing.cpp
svenjeschmitt-ops Feb 11, 2026
3ab0733
removed ParsingError
svenjeschmitt-ops Feb 11, 2026
c7da6a3
changing back pre-commit
svenjeschmitt-ops Feb 11, 2026
8a07f36
fix linter
svenjeschmitt-ops Feb 11, 2026
6ce28c0
fix linter 2
svenjeschmitt-ops Feb 11, 2026
7ea1084
parsing removed
svenjeschmitt-ops Feb 12, 2026
0606738
Merge remote-tracking branch 'upstream/main'
svenjeschmitt-ops Feb 13, 2026
fdfd0c8
fix CI
svenjeschmitt-ops Feb 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ jobs:
runs-on: ubuntu-slim
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
allowed-skips: >-
env:
NEEDS_JSON: ${{ toJSON(needs) }}
ALLOWED_SKIPS: >-
${{
fromJSON(needs.change-detection.outputs.run-cpp-tests)
&& '' || 'cpp-tests-ubuntu,cpp-tests-macos,cpp-tests-windows,'
Expand All @@ -193,4 +193,39 @@ jobs:
fromJSON(needs.change-detection.outputs.run-cd)
&& '' || 'build-sdist,build-wheel'
}}
jobs: ${{ toJSON(needs) }}
ALLOWED_CANCELS: cpp-tests-windows
ALLOWED_FAILURES: ""
run: |
python - <<'PY'
import json
import os
import sys

def split_csv(value: str) -> set[str]:
return {item for item in value.replace("\n", "").split(",") if item}

needs = json.loads(os.environ["NEEDS_JSON"])
allowed_skips = split_csv(os.environ.get("ALLOWED_SKIPS", ""))
allowed_cancels = split_csv(os.environ.get("ALLOWED_CANCELS", ""))
allowed_failures = split_csv(os.environ.get("ALLOWED_FAILURES", ""))

failures = []
for job, info in needs.items():
result = (info or {}).get("result")
if result == "success":
continue
if result == "skipped" and job in allowed_skips:
continue
if result == "cancelled" and job in allowed_cancels:
continue
if result == "failure" and job in allowed_failures:
continue
failures.append(f"{job} => {result}")

if failures:
print("Some of the required jobs failed or were cancelled:")
for item in failures:
print(f" - {item}")
sys.exit(1)
print("All required jobs are green (or allowed to skip/cancel/fail).")
PY
42 changes: 40 additions & 2 deletions bindings/InterfaceBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,41 @@ struct StatevectorCPP {

// NOLINTNEXTLINE(misc-use-internal-linkage)
void bindFramework(nb::module_& m) {
// Bind the Result enum
nb::enum_<Result>(m, "Result", "Represents the result of an operation.")
.value("OK", OK, "Indicates that the operation was successful.")
.value("ERROR", ERROR, "Indicates that an error occurred.");

// Bind the LoadResultStatus enum
nb::enum_<LoadResultStatus>(
m, "LoadResultStatus",
"Represents the result of a code loading operation.")
.value("OK", LOAD_OK, "Indicates that the code was loaded successfully.")
.value("PARSE_ERROR", LOAD_PARSE_ERROR,
"Indicates that the code could not be parsed.")
.value("INTERNAL_ERROR", LOAD_INTERNAL_ERROR,
"Indicates that an internal error occurred while loading.");

// Bind the LoadResult struct
nb::class_<LoadResult>(m, "LoadResult")
.def(nb::init<>())
.def_rw("status", &LoadResult::status,
"Indicates whether the load was successful and why it failed.")
.def_rw("line", &LoadResult::line,
"The line number of the error location, or 0 if unknown.")
.def_rw("column", &LoadResult::column,
"The column number of the error location, or 0 if unknown.")
.def_prop_ro(
"message",
[](const LoadResult& self) {
if (self.message == nullptr) {
return nb::none();
}
return nb::cast(std::string(self.message));
},
"A human-readable error message, or None if none is available.")
Comment on lines +89 to +97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Minor: Consider explicit return type for message lambda.

The lambda returns nb::none() (type nb::handle) and nb::cast(...) (type nb::object). While this works due to implicit conversions, an explicit return type would improve clarity and prevent potential issues if nanobind internals change.

♻️ Optional: Explicit return type
       .def_prop_ro(
           "message",
-          [](const LoadResult& self) {
+          [](const LoadResult& self) -> nb::object {
             if (self.message == nullptr) {
               return nb::none();
             }
             return nb::cast(std::string(self.message));
           },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.def_prop_ro(
"message",
[](const LoadResult& self) {
if (self.message == nullptr) {
return nb::none();
}
return nb::cast(std::string(self.message));
},
"A human-readable error message, or None if none is available.")
.def_prop_ro(
"message",
[](const LoadResult& self) -> nb::object {
if (self.message == nullptr) {
return nb::none();
}
return nb::cast(std::string(self.message));
},
"A human-readable error message, or None if none is available.")
🤖 Prompt for AI Agents
In `@bindings/InterfaceBindings.cpp` around lines 79 - 87, The lambda used in
def_prop_ro for the "message" property on LoadResult mixes nb::none() and
nb::cast(...) types; make its return type explicit (e.g., nb::object) to ensure
consistent return typing and avoid implicit conversion issues—update the lambda
signature in the def_prop_ro call for "message" on LoadResult to explicitly
return nb::object and return nb::none() or nb::cast(std::string(self.message))
accordingly.

.doc() = "The result of a code loading operation.";

// Bind the VariableType enum
nb::enum_<VariableType>(m, "VariableType",
"The type of a classical variable.")
Expand Down Expand Up @@ -164,13 +199,16 @@ Contains one element for each of the `num_states` states in the state vector.)")
.def(
"load_code",
[](SimulationState* self, const char* code) {
checkOrThrow(self->loadCode(self, code));
return self->loadCode(self, code);
},
"code"_a,
R"(Loads the given code into the simulation state.

Args:
code: The code to load.)")
code: The code to load.

Returns:
LoadResult: The result of the load operation.)")
.def(
"step_forward",
[](SimulationState* self) { checkOrThrow(self->stepForward(self)); },
Expand Down
8 changes: 6 additions & 2 deletions include/backend/dd/DDSimDebug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ struct DDSimulationState {
* @brief The code being executed, after preprocessing.
*/
std::string processedCode;
/**
* @brief The most recent load error detail message.
*/
std::string lastLoadErrorDetail;
/**
* @brief Indicates whether the debugger is ready to start simulation.
*/
Expand Down Expand Up @@ -277,9 +281,9 @@ Result ddsimInit(SimulationState* self);
* @brief Loads the given code into the simulation state.
* @param self The instance to load the code into.
* @param code The code to load.
* @return The result of the operation.
* @return The result of the load operation.
*/
Result ddsimLoadCode(SimulationState* self, const char* code);
LoadResult ddsimLoadCode(SimulationState* self, const char* code);
/**
* @brief Steps the simulation forward by one instruction.
* @param self The instance to step forward.
Expand Down
4 changes: 2 additions & 2 deletions include/backend/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ struct SimulationStateStruct {
* @brief Loads the given code into the simulation state.
* @param self The instance to load the code into.
* @param code The code to load.
* @return The result of the operation.
* @return The result of the load operation.
*/
Result (*loadCode)(SimulationState* self, const char* code);
LoadResult (*loadCode)(SimulationState* self, const char* code);

/**
* @brief Steps the simulation forward by one instruction.
Expand Down
40 changes: 40 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,46 @@ typedef enum {
ERROR,
} Result;

/**
* @brief The result of a code loading operation.
*/
typedef enum {
/**
* @brief Indicates that the code was loaded successfully.
*/
LOAD_OK,
/**
* @brief Indicates that the code could not be parsed.
*/
LOAD_PARSE_ERROR,
/**
* @brief Indicates that an internal error occurred while loading the code.
*/
LOAD_INTERNAL_ERROR,
} LoadResultStatus;

/**
* @brief The result of a code loading operation.
*/
typedef struct {
/**
* @brief Indicates whether the load was successful and why it failed.
*/
LoadResultStatus status;
/**
* @brief The line number of the error location, or 0 if unknown.
*/
size_t line;
/**
* @brief The column number of the error location, or 0 if unknown.
*/
size_t column;
/**
* @brief A human-readable error message, or nullptr if none is available.
*/
const char* message;
Comment on lines +63 to +82
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, check if the file exists and read the relevant section
if [ -f "include/common.h" ]; then
  echo "=== File found, reading lines 63-82 ==="
  sed -n '63,82p' include/common.h
else
  echo "File not found, searching for common.h"
  find . -name "common.h" -type f | head -5
fi

Repository: munich-quantum-toolkit/debugger

Length of output: 607


🏁 Script executed:

# Search for how NULL/nullptr are used in documentation throughout the codebase
echo "=== Checking NULL vs nullptr usage in comments ==="
rg "nullptr|NULL" include/ --type c --type h -B 2 -A 2 | head -50

Repository: munich-quantum-toolkit/debugger

Length of output: 2512


🏁 Script executed:

# Check if this is a public C API header and how other fields are documented
echo "=== Checking for C API patterns and ownership documentation ==="
rg "@brief.*owned|@brief.*lifetime|ownership|lifetime" include/ --type h

Repository: munich-quantum-toolkit/debugger

Length of output: 138


🏁 Script executed:

# Get broader context of the file to understand if it's C-facing
echo "=== Checking file context and includes ==="
head -30 include/common.h

Repository: munich-quantum-toolkit/debugger

Length of output: 780


Use NULL instead of nullptr and clarify message ownership in this C-facing header.

The documentation uses nullptr (C++ convention) instead of NULL (C standard), which is inconsistent with other C headers in the codebase (e.g., include/backend/debug.h). Additionally, callers need to understand whether they own this pointer and if the lifetime extends beyond the call.

📝 Suggested doc fix
-  /**
-   * `@brief` A human-readable error message, or nullptr if none is available.
-   */
+  /**
+   * `@brief` A human-readable error message, or NULL if none is available.
+   *
+   * The pointer is owned by the library and should be copied immediately.
+   */
   const char* message;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* @brief The result of a code loading operation.
*/
typedef struct {
/**
* @brief Indicates whether the load was successful and why it failed.
*/
LoadResultStatus status;
/**
* @brief The line number of the error location, or 0 if unknown.
*/
size_t line;
/**
* @brief The column number of the error location, or 0 if unknown.
*/
size_t column;
/**
* @brief A human-readable error message, or nullptr if none is available.
*/
const char* message;
/**
* `@brief` The result of a code loading operation.
*/
typedef struct {
/**
* `@brief` Indicates whether the load was successful and why it failed.
*/
LoadResultStatus status;
/**
* `@brief` The line number of the error location, or 0 if unknown.
*/
size_t line;
/**
* `@brief` The column number of the error location, or 0 if unknown.
*/
size_t column;
/**
* `@brief` A human-readable error message, or NULL if none is available.
*
* The pointer is owned by the library and should be copied immediately.
*/
const char* message;
🤖 Prompt for AI Agents
In `@include/common.h` around lines 63 - 82, Replace the C++-style nullptr with
the C standard NULL in the documentation for the LoadResult struct and clarify
ownership/lifetime for the message field: update the comment on the const char*
message (in the LoadResult/LoadResultStatus-related typedef) to state that NULL
indicates no message, that the pointer is not owned by the caller and must not
be freed, and specify the pointer's lifetime (e.g., valid as long as the
LoadResult value remains valid or until the next load call) so callers know how
to manage it.

} LoadResult;

/**
* @brief The type of classical variables.
*
Expand Down
35 changes: 35 additions & 0 deletions include/common/parsing/CodePreprocessing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <cstddef>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <utility>
Expand Down Expand Up @@ -211,6 +212,24 @@ struct ClassicControlledGate {
std::vector<std::string> operations;
};

/**
* @brief Represents a parsed classic-controlled condition.
*/
struct ClassicCondition {
/**
* @brief The name of the classical register.
*/
std::string registerName;
/**
* @brief Optional bit index if the condition targets a single bit.
*/
std::optional<size_t> bitIndex;
/**
* @brief The expected value in the condition comparison.
*/
size_t expectedValue;
};

/**
* @brief Represents a function definition in the code.
*/
Expand Down Expand Up @@ -286,6 +305,22 @@ bool isClassicControlledGate(const std::string& line);
*/
ClassicControlledGate parseClassicControlledGate(const std::string& code);

/**
* @brief Parse a classic-controlled condition expression.
* @param condition The condition string to parse.
* @return The parsed condition, or std::nullopt if it cannot be parsed.
*/
std::optional<ClassicCondition>
parseClassicConditionExpression(const std::string& condition);

/**
* @brief Parse a classic-controlled condition from a classic-controlled gate.
* @param code The code to parse.
* @return The parsed condition, or std::nullopt if it cannot be parsed.
*/
std::optional<ClassicCondition>
parseClassicConditionFromCode(const std::string& code);

/**
* @brief Check if a given line is a variable declaration.
*
Expand Down
39 changes: 39 additions & 0 deletions include/common/parsing/ParsingError.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#include <cstddef>
#include <stdexcept>
#include <string>

Expand All @@ -30,6 +31,44 @@ class ParsingError : public std::runtime_error {
* @param msg The error message.
*/
explicit ParsingError(const std::string& msg);

/**
* @brief Constructs a new ParsingError with location information.
* @param line The one-based line number, or 0 if unknown.
* @param column The one-based column number, or 0 if unknown.
* @param detail The error detail message.
*/
ParsingError(size_t line, size_t column, std::string detail);

/**
* @brief Constructs a new ParsingError with location information and message.
* @param line The one-based line number, or 0 if unknown.
* @param column The one-based column number, or 0 if unknown.
* @param detail The error detail message.
* @param message The formatted error message.
*/
ParsingError(size_t line, size_t column, std::string detail,
const std::string& message);

/**
* @brief Gets the line number of the error location, or 0 if unknown.
*/
size_t line() const noexcept;

/**
* @brief Gets the column number of the error location, or 0 if unknown.
*/
size_t column() const noexcept;

/**
* @brief Gets the error detail message.
*/
const std::string& detail() const noexcept;

private:
size_t line_ = 0;
size_t column_ = 0;
std::string detail_;
};

} // namespace mqt::debugger
6 changes: 6 additions & 0 deletions python/mqt/debugger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
Diagnostics,
ErrorCause,
ErrorCauseType,
LoadResult,
LoadResultStatus,
Result,
SimulationState,
Statevector,
Variable,
Expand All @@ -33,6 +36,9 @@
"Diagnostics",
"ErrorCause",
"ErrorCauseType",
"LoadResult",
"LoadResultStatus",
"Result",
"SimulationState",
"Statevector",
"Variable",
Expand Down
42 changes: 26 additions & 16 deletions python/mqt/debugger/check/run_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,32 @@ def start_compilation(code: Path, output_dir: Path) -> None:
output_dir (Path): The directory to store the compiled slices.
"""
state = dbg.create_ddsim_simulation_state()
with code.open("r", encoding="utf-8") as f:
code_str = f.read()
state.load_code(code_str)
i = 0
while True:
i += 1
settings = dbg.CompilationSettings(
opt=0,
slice_index=i - 1,
)
compiled = state.compile(settings)
if not compiled:
break
with (output_dir / f"slice_{i}.qasm").open("w") as f:
f.write(compiled)
dbg.destroy_ddsim_simulation_state(state)
try:
with code.open("r", encoding="utf-8") as f:
code_str = f.read()
load_result = state.load_code(code_str)
if load_result.status != dbg.LoadResultStatus.OK:
message = load_result.message or "Error loading code"
raise RuntimeError(message)
i = 0
compiled_any = False
while True:
i += 1
settings = dbg.CompilationSettings(
opt=0,
slice_index=i - 1,
)
compiled = state.compile(settings)
if not compiled:
break
compiled_any = True
with (output_dir / f"slice_{i}.qasm").open("w") as f:
f.write(compiled)
if not compiled_any:
msg = "No compiled slices produced; check input code for validity."
raise RuntimeError(msg)
finally:
dbg.destroy_ddsim_simulation_state(state)


# -------------------------
Expand Down
Loading
Loading