Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- **Fixed** for any bug fixes.
- **Removed** for now removed features.

## [ 1.4.1 ] - [ 2026-06-15 ]

### Fixed
- Aliases `measureX`, `measureY`, and `measureZ`, for the `measure` instruction, recognized as tokens by the lexer.


## [ 1.4.0 ] - [ 2026-06-05 ]

### Added
- `CV`, `CY`, `DCNOT`, `ECR`, `ISWAP`, `InvSqrtSWAP`, `M`, `MS`, `SqrtISWAP`, and `SqrtSWAP` unitary instructions.
- Aliases `measureX`, `measureY`, and `measureZ`, for the `measure` instruction along the respective axes.

<<<<<<< HEAD
=======

>>>>>>> develop
## [ 1.3.0 ] - [ 2026-03-23 ]

### Added
Expand Down
7 changes: 7 additions & 0 deletions conan/profiles/tests-debug-local
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include(tests-debug)

[platform_tool_requires]
m4/1.4.19

[buildenv]
PATH+=(path)C:/msys64/usr/bin
2 changes: 1 addition & 1 deletion emscripten/test_libqasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ wrapper().then(function(result: any) {

try {
let output = cqasm.get_version()
let expected_output = "1.4.0"
let expected_output = "1.4.1"
console.log("\nThe version of libqasm compiled with emscripten is:", output);
if (output !== expected_output) {
console.log("\tExpected output:", expected_output)
Expand Down
2 changes: 1 addition & 1 deletion include/libqasm/versioning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace cqasm {

static const char* version{ "1.4.0" };
static const char* version{ "1.4.1" };
static const char* release_year{ "2026" };

[[nodiscard]] [[maybe_unused]] static const char* get_version() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libqasm",
"version": "1.4.0",
"version": "1.4.1",
"repository": {
"type": "git",
"url": "https://github.com/QuTech-Delft/libqasm.git"
Expand Down
2 changes: 1 addition & 1 deletion src/v3x/CqasmLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TERNARY_CONDITIONAL_OP: '?';

// Keywords
VERSION: 'version' -> pushMode(VERSION_STATEMENT); // version
MEASURE: 'measure'; // non-unitary instructions
MEASURE: 'measure' ('X' | 'Y' | 'Z')?; // non-unitary instructions
RESET: 'reset';
INIT: 'init';
BARRIER: 'barrier';
Expand Down
31 changes: 31 additions & 0 deletions test/v3x/cpp/test_analyzer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <fmt/format.h>
#include <gmock/gmock.h>

#include <functional>
Expand Down Expand Up @@ -48,6 +49,36 @@ TEST_F(AnalyzerAnalyzeTest, parser_returns_errors) {
EXPECT_THAT(error.what(), ::testing::HasSubstr(parse_error_message));
}

TEST_F(AnalyzerAnalyzeTest, analyze_string_with_measure_aliases) {
auto analyzer = Analyzer{};
analyzer.register_default_constants();
analyzer.register_default_functions();
analyzer.register_default_instructions();

const auto program = std::string{
"version 3\n"
"qubit qx\n"
"qubit qy\n"
"qubit qz\n"
"bit bx\n"
"bit by\n"
"bit bz\n"
"bx = measureX qx\n"
"by = measureY qy\n"
"bz = measureZ qz\n"
};

const auto& analysis_result = analyzer.analyze_string(program, "input.cq");

EXPECT_TRUE(analysis_result.errors.empty());
ASSERT_TRUE(analysis_result.root.is_well_formed());

const auto semantic_dump = fmt::format("{}", *analysis_result.root);
EXPECT_THAT(semantic_dump, ::testing::HasSubstr("instruction_ref: measureX(bit, qubit)"));
EXPECT_THAT(semantic_dump, ::testing::HasSubstr("instruction_ref: measureY(bit, qubit)"));
EXPECT_THAT(semantic_dump, ::testing::HasSubstr("instruction_ref: measureZ(bit, qubit)"));
}

//--------------//
// AnalyzerTest //
//--------------//
Expand Down
28 changes: 28 additions & 0 deletions test/v3x/python/test_v3x_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ def test_measure_instruction_overload(self):
expected_errors = ["Error at <unknown file name>:1:29..36: instruction 'measure' does not have an overload with 2 parameters."]
self.assertEqual(errors, expected_errors)

def test_measure_aliases(self):
program_str = (
"version 3;"
"qubit qx;qubit qy;qubit qz;"
"bit bx;bit by;bit bz;"
"bx = measureX qx;"
"by = measureY qy;"
"bz = measureZ qz"
)
v3x_analyzer = cq.Analyzer()
ast = v3x_analyzer.analyze_string(program_str)

for statement, expected_name, expected_bit, expected_qubit in zip(
ast.block.statements,
("measureX", "measureY", "measureZ"),
("bx", "by", "bz"),
("qx", "qy", "qz"),
):
self.assertEqual(statement.name, expected_name)

bit_operand = statement.operands[0]
self.assertEqual(bit_operand.variable.name, expected_bit)
self.assertIsInstance(bit_operand.variable.typ, cq.types.Bit)

qubit_operand = statement.operands[1]
self.assertEqual(qubit_operand.variable.name, expected_qubit)
self.assertIsInstance(qubit_operand.variable.typ, cq.types.Qubit)

def test_parse_string_returning_ast(self):
program_str = "version 3;qubit[5] q;bit[5] b;H q[0:4];b = measure q"
v3x_analyzer = cq.Analyzer()
Expand Down
Loading