├── .clang-format ├── .clang-tidy ├── .dockerignore ├── .gitattributes ├── .github ├── actions │ ├── cpp-tests │ │ └── action.yaml │ └── python-tests │ │ └── action.yaml └── workflows │ ├── assets.yaml │ ├── doc.yaml │ ├── linters.yaml │ └── test.yaml ├── .gitignore ├── CHANGELOG.md ├── CMakeLists.txt ├── Dockerfile ├── LICENSE.md ├── README.md ├── conan └── profiles │ ├── debug │ ├── debug-gcc-linux-x64-shared │ ├── release │ ├── release-clang-emscripten-wasm │ ├── release-gcc-linux-x64-shared │ ├── tests-debug │ ├── tests-debug-apple_clang-macos-arm64 │ ├── tests-debug-apple_clang-macos-x64 │ ├── tests-debug-clang-linux-arm64 │ ├── tests-debug-clang-linux-x64 │ ├── tests-debug-gcc-linux-arm64 │ ├── tests-debug-gcc-linux-x64 │ ├── tests-debug-msvc-windows-x64 │ ├── tests-release │ ├── tests-release-apple_clang-macos-arm64 │ ├── tests-release-apple_clang-macos-x64 │ ├── tests-release-clang-linux-arm64 │ ├── tests-release-clang-linux-x64 │ ├── tests-release-gcc-linux-arm64 │ ├── tests-release-gcc-linux-x64 │ └── tests-release-msvc-windows-x64 ├── conanfile.py ├── docs ├── about │ ├── authors.md │ ├── contributing.md │ ├── license.md │ └── release-notes.md ├── api │ ├── cpp-api.md │ ├── emscripten-api.md │ └── python-api.md ├── cpp_highlight.js ├── dev-guide │ ├── cpp-dev-guide.md │ ├── dev-guide.md │ ├── emscripten-dev-guide.md │ └── python-dev-guide.md ├── extra_api.css ├── extra_highlight.css ├── index.md ├── python_highlight.js ├── typescript_highlight.js └── user-guide │ ├── cpp-user-guide.md │ ├── docker.md │ ├── emscripten-user-guide.md │ ├── python-user-guide.md │ └── user-guide.md ├── emscripten ├── CMakeLists.txt ├── emscripten_wrapper.cpp ├── emscripten_wrapper.hpp └── test_libqasm.ts ├── include └── libqasm │ ├── annotations.hpp │ ├── annotations_constants.hpp │ ├── cqasm.hpp │ ├── error.hpp │ ├── overload.hpp │ ├── result.hpp │ ├── string_builder.hpp │ ├── tree.hpp │ ├── utils.hpp │ ├── v3x │ ├── analysis_result.hpp │ ├── analyzer.hpp │ ├── antlr_custom_error_listener.hpp │ ├── antlr_scanner.hpp │ ├── core_function.hpp │ ├── cqasm.hpp │ ├── cqasm_python.hpp │ ├── instruction.hpp │ ├── instruction_set.hpp │ ├── parse_helper.hpp │ ├── parse_result.hpp │ ├── primitives.hpp │ ├── register_consteval_core_functions.hpp │ ├── register_instructions.hpp │ ├── resolver.hpp │ ├── scope.hpp │ ├── semantic.hpp │ ├── semantic_analyzer.hpp │ ├── semantic_helper.hpp │ ├── syntactic.hpp │ ├── syntactic_analyzer.hpp │ ├── syntactic_analyzer_base.hpp │ ├── types.hpp │ └── values.hpp │ ├── version.hpp │ └── versioning.hpp ├── mkdocs-base.yaml ├── mkdocs.yaml ├── package.json ├── pyproject.toml ├── pytest.ini ├── python ├── CMakeLists.txt ├── README.md ├── libqasm.i ├── module │ ├── cqasm │ │ ├── __init__.py │ │ └── v3x │ │ │ ├── __init__.py │ │ │ ├── instruction.py │ │ │ └── primitives.py │ └── libqasm │ │ └── __init__.py ├── python_lib.py └── test_libqasm.py ├── requirements.txt ├── res └── v3x │ └── tests │ └── integration │ ├── asm_declaration │ ├── empty_raw_text_string │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── invalid_backend_name │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── invalid_missing_end_triple_quote_raw_string │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── valid_multiline_raw_text_string │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── valid_raw_text_string │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── barrier_instruction │ ├── 5 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── no_operand │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── q_range_0_4 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit_array_definition │ ├── bit_array_of_0_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit_array_of_123abc │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_17 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_17_1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_17_3.14 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_17_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit_array_of_17_b0_b1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_17_b0_comma_b1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_17_b__bit_array_of_17_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit_array_of_17_b_at_0 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_17_equal │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_3.14 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_array_of_b │ │ ├── ast.golden.txt │ │ └── input.cq │ └── bit_array_of_equal │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_definition │ ├── bbit_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_123abc │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_3.14 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit_b0_b1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_b0_comma_b1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bit_b__bit_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit_b_at_0 │ │ ├── ast.golden.txt │ │ └── input.cq │ └── bit_equal │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── case_sensitiveness │ ├── eu_uppercase │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── pi_uppercase │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_uppercase │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_all_uppercase │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_camel_case │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── tau_uppercase │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── version_all_uppercase │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── version_camel_case │ │ ├── ast.golden.txt │ │ └── input.cq │ └── x_lowercase │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── comments │ ├── multi_line │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── multi_line_then_error │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── multi_line_within_single_line │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── open_multi_line_within_single_line │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── python_style_before_version │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── python_style_single_line │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── single_line │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── single_line_and_multi_line_before_version │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── single_line_then_error │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── single_line_within_multi_line │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── eof │ └── error_right_before_eof │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── eu_pi_tau │ ├── qubit_q__Rx_eu_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_q__Rx_pi_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── qubit_q__Rx_tau_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── expression │ ├── out_of_bounds_index │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── out_of_range_float_literal │ │ ├── ast.golden.txt │ │ └── input.cq │ └── out_of_range_integer_literal │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── expression_list │ ├── bad_first_part │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── bad_second_part │ │ ├── ast.golden.txt │ │ └── input.cq │ └── no_second_part │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── gate_modifier │ ├── X_inv_q │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── adj_X_q │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── ctrl_X_q │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ ├── ctrl_X_q_0_q_1 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ ├── ctrl_X_q_range_0_1 │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ ├── inv_inv_X_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ ├── inv_reset │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── inv_x_q │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ ├── pow_2_X_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ ├── pow_2_inv_ctrl_X_q_0_q_1 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ └── pow_b_X_q │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── init_instruction │ ├── 5 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── no_operand │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── q_range_0_4 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── instruction │ ├── X │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── X_1 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── X_123abc │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── X_3.14 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── X_q0 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── X_v │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_2__H_q_0__H_q_1__CNOT_q_0_q_1 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_q__X_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── v_1 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── measure_instruction │ ├── array_of_3_q_to_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── array_of_5_q_to_array_of_5_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── array_of_5_q_to_array_of_9_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── array_of_5_q_to_b_range_0_4 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── array_of_5_q_to_b_range_2_6 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── array_of_9_q_to_array_of_5_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── b_to_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── b_to_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── bit_and_qubit │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── no_bit │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── no_bit_no_qubit │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── no_qubit │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── q0_to_array_of_3_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q0_to_b_0 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_0_to_b0 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_1_3_4_5_7_to_array_of_5_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_2_4_to_b_1_3 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_2_4_to_b_range_1_2 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_range_0_4_to_array_of_5_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_range_2_6_to_array_of_5_b │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_range_3_4_to_b_1_3 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── q_to_5 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── q_to_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── newline_or_semicolon │ ├── qubit_newline_q │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── version_3_newline_qubit_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── version_3_semicolon_qubit_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── program │ ├── bad_token_after_version │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── newlines_before_version │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── no_statement_separators_after_last_statement │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── no_statement_separators_after_version │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── statement_separators_after_statements │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── statement_separators_before_eof │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── statement_separators_between_statements │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_array_definition │ ├── qubit_array_of_0_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_array_of_123abc │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_17 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_17_1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_17_3.14 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_17_equal │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_17_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_array_of_17_q0_comma_q1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_17_q0_q1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_17_q__qubit_array_of_17_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_array_of_17_q_at_0 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_3.14_q │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_array_of_equal │ │ ├── ast.golden.txt │ │ └── input.cq │ └── qubit_array_of_q │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_definition │ ├── qqubit_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_123abc │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_equal │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_q0_comma_q1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_q0_q1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── qubit_q1__qubit_q2 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── qubit_q__qubit_q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── qubit_q_at_0 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── reset_instruction │ ├── 5 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── no_operand │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── q │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ └── q_range_0_4 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── sgmq │ ├── cnot_q_0_1_q_3_2 │ │ ├── ast.golden.json │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ ├── semantic.3.0.golden.json │ │ └── semantic.3.0.golden.txt │ └── cnot_q_0_q_3_2 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── version │ ├── empty │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── instruction_and_version_3.0 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── instruction_called_version │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── no_version_and_instruction │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── version_1.0 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── version_2.0 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── version_3.0 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── version_3.2.1 │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── version_3 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── version_30.20 │ │ ├── ast.golden.txt │ │ ├── input.cq │ │ └── semantic.3.0.golden.txt │ ├── version_3__version_3__qubit_q │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── version_3_dot │ │ ├── ast.golden.txt │ │ └── input.cq │ ├── version_no_number │ │ ├── ast.golden.txt │ │ └── input.cq │ └── vrsion │ │ ├── ast.golden.txt │ │ └── input.cq │ └── wait_instruction │ ├── wait │ ├── ast.golden.txt │ └── input.cq │ ├── wait_0_q │ ├── ast.golden.txt │ ├── input.cq │ └── semantic.3.0.golden.txt │ ├── wait_1.5_q │ ├── ast.golden.txt │ ├── input.cq │ └── semantic.3.0.golden.txt │ ├── wait_1 │ ├── ast.golden.txt │ └── input.cq │ ├── wait_2_q │ ├── ast.golden.txt │ ├── input.cq │ └── semantic.3.0.golden.txt │ ├── wait_2_q_range_0_4 │ ├── ast.golden.txt │ ├── input.cq │ └── semantic.3.0.golden.txt │ └── wait_m1_q │ ├── ast.golden.txt │ ├── input.cq │ └── semantic.3.0.golden.txt ├── scripts ├── generate_antlr_parser.py ├── python │ └── mkdocstrings_handlers │ │ ├── cpp │ │ ├── __init__.py │ │ └── templates │ │ │ └── README │ │ ├── emscripten │ │ ├── __init__.py │ │ └── templates │ │ │ └── README │ │ └── python │ │ ├── __init__.py │ │ └── templates │ │ └── README └── run_cpp_linters.py ├── setup.py ├── src ├── CMakeLists.txt ├── annotations.cpp ├── error.cpp ├── string_builder.cpp ├── utils.cpp ├── v3x │ ├── CMakeLists.txt │ ├── CqasmLexer.g4 │ ├── CqasmParser.g4 │ ├── analysis_result.cpp │ ├── analyzer.cpp │ ├── antlr_custom_error_listener.cpp │ ├── antlr_scanner.cpp │ ├── core_function.cpp │ ├── cqasm.cpp │ ├── cqasm_python.cpp │ ├── instruction.cpp │ ├── instruction_set.cpp │ ├── parse_helper.cpp │ ├── parse_result.cpp │ ├── primitives.cpp │ ├── register_consteval_core_functions.cpp │ ├── register_instructions.cpp │ ├── resolver.cpp │ ├── semantic.tree │ ├── semantic_analyzer.cpp │ ├── syntactic.tree │ ├── syntactic_analyzer.cpp │ ├── types.cpp │ ├── types.tree │ ├── values.cpp │ └── values.tree └── version.cpp ├── test ├── CMakeLists.txt ├── main.cpp ├── register_integration_tests.hpp ├── test_annotations.cpp ├── test_error.cpp ├── test_result.cpp ├── test_utils.cpp ├── utils.cpp ├── utils.hpp └── v3x │ ├── CMakeLists.txt │ ├── __init__.py │ ├── cpp │ ├── CMakeLists.txt │ ├── integration_test.cpp │ ├── integration_test.hpp │ ├── matcher_values.cpp │ ├── matcher_values.hpp │ ├── mock_analyzer.hpp │ ├── mock_scanner_adaptor.hpp │ ├── mock_semantic_analyzer.hpp │ ├── test_analyzer.cpp │ ├── test_functions.cpp │ ├── test_functions.hpp │ ├── test_instruction_set.cpp │ ├── test_parse_helper.cpp │ ├── test_semantic_analyzer.cpp │ └── test_values.cpp │ └── python │ ├── __init__.py │ ├── test_analysis_result.py │ ├── test_parse_result.py │ └── test_v3x_analyzer.py └── version.py /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: Google 3 | Language: Cpp 4 | AccessModifierOffset: -4 5 | AlignAfterOpenBracket: DontAlign 6 | AlignArrayOfStructures: Right 7 | AlignOperands: DontAlign 8 | AlignTrailingComments: false 9 | AllowAllArgumentsOnNextLine: true 10 | AllowAllParametersOfDeclarationOnNextLine: true 11 | AllowShortEnumsOnASingleLine: true 12 | AllowShortBlocksOnASingleLine: Never 13 | AllowShortCaseLabelsOnASingleLine: true 14 | AllowShortIfStatementsOnASingleLine: AllIfsAndElse 15 | AllowShortFunctionsOnASingleLine: Inline 16 | AllowShortLambdasOnASingleLine: All 17 | AllowShortLoopsOnASingleLine: true 18 | AlwaysBreakTemplateDeclarations: Yes 19 | BinPackArguments: false 20 | BreakBeforeBraces: Attach 21 | # Use BraceWrapping with custom BreakBeforeBraces 22 | # BreakBeforeBraces: Custom 23 | # BraceWrapping: 24 | BreakBeforeTernaryOperators: true 25 | BreakConstructorInitializers: BeforeComma 26 | ColumnLimit: 120 27 | ConstructorInitializerIndentWidth: 0 28 | Cpp11BracedListStyle: false 29 | DerivePointerAlignment: false 30 | IndentCaseLabels: true 31 | IndentWidth: 4 32 | LambdaBodyIndentation: Signature 33 | PackConstructorInitializers: Never 34 | PointerAlignment: Left 35 | QualifierAlignment: Left 36 | ReferenceAlignment: Left 37 | ReflowComments: true 38 | SpacesBeforeTrailingComments: 2 39 | Standard: c++20 40 | --- 41 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /.git 2 | /Dockerfile 3 | /build 4 | /cbuild 5 | /pybuild 6 | /.eggs 7 | /.pytest_cache 8 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Declare files that will always have LF line endings on checkout. 5 | # 6 | # Reading and writing of "actual test files" (e.g. ast.actual.txt) use LF line endings 7 | # (see read_file and write_file implementation in utils.{hpp,cpp}) 8 | # Since we are comparing the actual test files against "golden test files" (e.g. ast.golden.txt), 9 | # we also want the golden test files to use LF line endings. 10 | res/v3x/tests/integration/*/*/*.* text eol=lf 11 | -------------------------------------------------------------------------------- /.github/actions/python-tests/action.yaml: -------------------------------------------------------------------------------- 1 | name: Python tests 2 | description: Install and run tests in Python 3 | inputs: 4 | shell: 5 | required: true 6 | description: Which shell to use for the `run` command 7 | 8 | runs: 9 | using: composite 10 | steps: 11 | - uses: actions/setup-python@v5 12 | with: 13 | python-version: "3.11" 14 | - name: Get latest CMake 15 | uses: lukka/get-cmake@latest 16 | - name: Install Python dependencies 17 | run: | 18 | python -m pip install --upgrade pip conan pytest setuptools wheel 19 | shell: ${{ inputs.shell }} 20 | - name: Build 21 | run: | 22 | python -m pip install --verbose . 23 | shell: ${{ inputs.shell }} 24 | - name: Run unit tests 25 | run: | 26 | python -m pytest 27 | shell: ${{ inputs.shell }} 28 | - name: Test libqasm 29 | working-directory: python 30 | run: | 31 | python test_libqasm.py 32 | shell: bash 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright [2018] [QCA Lab, QuTech, TU Delft] 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /conan/profiles/debug: -------------------------------------------------------------------------------- 1 | include(default) 2 | 3 | [settings] 4 | compiler.cppstd=20 5 | build_type=Debug 6 | 7 | [options] 8 | libqasm/*:asan_enabled=False 9 | 10 | [replace_requires] 11 | nodejs/*: nodejs/16.20.2 12 | -------------------------------------------------------------------------------- /conan/profiles/debug-gcc-linux-x64-shared: -------------------------------------------------------------------------------- 1 | include(debug) 2 | 3 | [options] 4 | */*:shared=True 5 | -------------------------------------------------------------------------------- /conan/profiles/release: -------------------------------------------------------------------------------- 1 | include(default) 2 | 3 | [settings] 4 | compiler.cppstd=20 5 | build_type=Release 6 | 7 | [options] 8 | libqasm/*:asan_enabled=False 9 | 10 | [replace_requires] 11 | nodejs/*: nodejs/16.20.2 12 | -------------------------------------------------------------------------------- /conan/profiles/release-clang-emscripten-wasm: -------------------------------------------------------------------------------- 1 | [settings] 2 | arch=wasm 3 | os=Emscripten 4 | build_type=Release 5 | compiler=clang 6 | compiler.version=14 7 | -------------------------------------------------------------------------------- /conan/profiles/release-gcc-linux-x64-shared: -------------------------------------------------------------------------------- 1 | include(release) 2 | 3 | [options] 4 | */*:shared=True 5 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug: -------------------------------------------------------------------------------- 1 | include(default) 2 | 3 | [settings] 4 | compiler.cppstd=20 5 | build_type=Debug 6 | 7 | [options] 8 | libqasm/*:asan_enabled=True 9 | 10 | [conf] 11 | tools.build:skip_test=False 12 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug-apple_clang-macos-arm64: -------------------------------------------------------------------------------- 1 | include(tests-debug) 2 | 3 | [settings] 4 | compiler=apple-clang 5 | compiler.version=14 6 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug-apple_clang-macos-x64: -------------------------------------------------------------------------------- 1 | include(tests-debug) 2 | 3 | [settings] 4 | compiler=apple-clang 5 | compiler.version=14 6 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug-clang-linux-arm64: -------------------------------------------------------------------------------- 1 | include(tests-debug) 2 | 3 | [settings] 4 | compiler=clang 5 | compiler.version=14 6 | 7 | [conf] 8 | tools.build:cxxflags=["-stdlib=libc++"] 9 | tools.build:compiler_executables={ 'c' : 'clang', 'cpp' : 'clang++' } 10 | 11 | [options] 12 | # Disable ASAN for Linux/x64 because we are having problems with gtest and address sanitizer 13 | # Possible hints: libc++ ABI compatibility, small string optimization 14 | libqasm/*:asan_enabled=False 15 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug-clang-linux-x64: -------------------------------------------------------------------------------- 1 | include(tests-debug) 2 | 3 | [settings] 4 | compiler=clang 5 | compiler.version=14 6 | 7 | [conf] 8 | tools.build:cxxflags=["-stdlib=libc++"] 9 | tools.build:compiler_executables={ 'c' : 'clang', 'cpp' : 'clang++' } 10 | 11 | [options] 12 | # Disable ASAN for Linux/x64 because we are having problems with gtest and address sanitizer 13 | # Possible hints: libc++ ABI compatibility, small string optimization 14 | libqasm/*:asan_enabled=False 15 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug-gcc-linux-arm64: -------------------------------------------------------------------------------- 1 | include(tests-debug) 2 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug-gcc-linux-x64: -------------------------------------------------------------------------------- 1 | include(tests-debug) 2 | 3 | [options] 4 | # Disable ASAN for Linux/x64 because we are having problems with gtest and address sanitizer 5 | # Possible hints: libc++ ABI compatibility, small string optimization 6 | libqasm/*:asan_enabled=False 7 | -------------------------------------------------------------------------------- /conan/profiles/tests-debug-msvc-windows-x64: -------------------------------------------------------------------------------- 1 | include(tests-debug) -------------------------------------------------------------------------------- /conan/profiles/tests-release: -------------------------------------------------------------------------------- 1 | include(default) 2 | 3 | [settings] 4 | compiler.cppstd=20 5 | build_type=Release 6 | 7 | [options] 8 | libqasm/*:asan_enabled=True 9 | 10 | [conf] 11 | tools.build:skip_test=False 12 | -------------------------------------------------------------------------------- /conan/profiles/tests-release-apple_clang-macos-arm64: -------------------------------------------------------------------------------- 1 | include(tests-release) 2 | 3 | [settings] 4 | compiler=apple-clang 5 | compiler.version=14 6 | -------------------------------------------------------------------------------- /conan/profiles/tests-release-apple_clang-macos-x64: -------------------------------------------------------------------------------- 1 | include(tests-release) 2 | 3 | [settings] 4 | compiler=apple-clang 5 | compiler.version=14 6 | -------------------------------------------------------------------------------- /conan/profiles/tests-release-clang-linux-arm64: -------------------------------------------------------------------------------- 1 | include(tests-release) 2 | 3 | [settings] 4 | compiler=clang 5 | compiler.version=14 6 | 7 | [conf] 8 | tools.build:cxxflags=["-stdlib=libc++"] 9 | tools.build:compiler_executables={ 'c' : 'clang', 'cpp' : 'clang++' } 10 | 11 | [options] 12 | # Disable ASAN for Linux/x64 because we are having problems with gtest and address sanitizer 13 | # Possible hints: libc++ ABI compatibility, small string optimization 14 | libqasm/*:asan_enabled=False 15 | -------------------------------------------------------------------------------- /conan/profiles/tests-release-clang-linux-x64: -------------------------------------------------------------------------------- 1 | include(tests-release) 2 | 3 | [settings] 4 | compiler=clang 5 | compiler.version=14 6 | 7 | [conf] 8 | tools.build:cxxflags=["-stdlib=libc++"] 9 | tools.build:compiler_executables={ 'c' : 'clang', 'cpp' : 'clang++' } 10 | 11 | [options] 12 | # Disable ASAN for Linux/x64 because we are having problems with gtest and address sanitizer 13 | # Possible hints: libc++ ABI compatibility, small string optimization 14 | libqasm/*:asan_enabled=False 15 | -------------------------------------------------------------------------------- /conan/profiles/tests-release-gcc-linux-arm64: -------------------------------------------------------------------------------- 1 | include(tests-release) 2 | 3 | [conf] 4 | tools.build:cxxflags=["-Wno-error=maybe-uninitialized"] 5 | -------------------------------------------------------------------------------- /conan/profiles/tests-release-gcc-linux-x64: -------------------------------------------------------------------------------- 1 | include(tests-release) 2 | 3 | [options] 4 | # Disable ASAN for Linux/x64 because we are having problems with gtest and address sanitizer 5 | # Possible hints: libc++ ABI compatibility, small string optimization 6 | libqasm/*:asan_enabled=False 7 | -------------------------------------------------------------------------------- /conan/profiles/tests-release-msvc-windows-x64: -------------------------------------------------------------------------------- 1 | include(tests-release) 2 | -------------------------------------------------------------------------------- /docs/about/authors.md: -------------------------------------------------------------------------------- 1 | libQASM is developed as part of the Quantum Inspire project: 2 | [support@quantum-inspire.com](mailto:"support@quantum-inspire.com") 3 | -------------------------------------------------------------------------------- /docs/about/contributing.md: -------------------------------------------------------------------------------- 1 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. 2 | Any contributions you make are greatly appreciated. 3 | 4 | If you have a suggestion that would make this better, please fork the repo and create a pull request. 5 | 6 | 1. Fork the project. 7 | 2. Create your feature branch (`git checkout -b feature/AmazingFeature`). 8 | 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`). 9 | 4. Push to the branch (`git push origin feature/AmazingFeature`). 10 | 5. Open a pull request. 11 | -------------------------------------------------------------------------------- /docs/about/license.md: -------------------------------------------------------------------------------- 1 | libQASM is licensed under the Apache License, Version 2.0. 2 | See [LICENSE](https://github.com/QuTech-Delft/OpenSquirrel/blob/master/LICENSE.md) for the full license text. 3 | -------------------------------------------------------------------------------- /docs/about/release-notes.md: -------------------------------------------------------------------------------- 1 | !!! info "Coming soon" 2 | -------------------------------------------------------------------------------- /docs/api/cpp-api.md: -------------------------------------------------------------------------------- 1 | libQASM C++ API is defined in `include/v3x/cqasm_python.hpp`. 2 | 3 | The only exported class is `V3xAnalyzer`. 4 | This is actually a C++ class that works as a binding for accessing C++ code from Python. 5 | 6 | ::: V3xAnalyzer 7 | handler: cpp 8 | -------------------------------------------------------------------------------- /docs/api/emscripten-api.md: -------------------------------------------------------------------------------- 1 | libQASM is also deployed as an Emscripten binary with a Typescript frontend. 2 | 3 | libQASM Typescript API is defined in `emscripten/emscripten_wrapper.hpp`. 4 | 5 | The only exported class is `EmscriptenWrapper`. 6 | This is actually a C++ class that works as a binding for accessing C++ code from Typescript. 7 | 8 | ::: EmscriptenWrapper 9 | handler: emscripten 10 | -------------------------------------------------------------------------------- /docs/api/python-api.md: -------------------------------------------------------------------------------- 1 | libQASM Python API is defined in `python/module/cqasm/v3x/__init__.py`. 2 | 3 | The only exported class is `Analyzer`. 4 | This is actually a Python class that works as a binding for accessing C++ code from Python. 5 | 6 | ::: Analyzer 7 | handler: python 8 | -------------------------------------------------------------------------------- /docs/cpp_highlight.js: -------------------------------------------------------------------------------- 1 | document$.subscribe(() => { 2 | hljs.highlightAll(), 3 | { language: 'c++' } 4 | }) 5 | -------------------------------------------------------------------------------- /docs/dev-guide/cpp-dev-guide.md: -------------------------------------------------------------------------------- 1 | You can build the C++ binaries from the project's root directory. 2 | The following line will also build and cache the `libqasm` Conan package. 3 | 4 | !!! note 5 | 6 | You may need to execute the `conan profile detect` command if this is the first time you run Conan. 7 | 8 | ```shell 9 | conan profile detect 10 | conan create --version 1.2.0 . -pr:a=tests-debug -b missing 11 | ``` 12 | 13 | You can test the C++ binaries: 14 | 15 | ```shell 16 | cd test/Debug 17 | ctest -C Debug --output-on-failure --parallel 10 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/dev-guide/emscripten-dev-guide.md: -------------------------------------------------------------------------------- 1 | You can build the Emscripten binaries from the project's root directory. 2 | The generation of Emscripten binaries has been tested as a cross-compilation from an ubuntu/x64 platform. 3 | 4 | ```shell 5 | conan build . -pr=conan/profiles/release-clang-emscripten-wasm -pr:b=conan/profiles/release -b missing 6 | ``` 7 | 8 | The output of this build lives in `build/Release/emscripten`: 9 | 10 | - `cqasm_emscripten.js`. 11 | - `cqasm_emscripten.wasm`. 12 | 13 | !!! note 14 | 15 | `cqasm_emscripten.js` is an ES6 module. 16 | Its extension has to be renamed to `.mjs` before using it from Typescript code. 17 | 18 | You can test the Emscripten binaries: 19 | 20 | ```shell 21 | cd build/Release/emscripten 22 | mv cqasm_emscripten.js cqasm_emscripten.mjs 23 | cd ../../../emscripten 24 | deno run -A test_libqasm.ts 25 | ``` 26 | -------------------------------------------------------------------------------- /docs/dev-guide/python-dev-guide.md: -------------------------------------------------------------------------------- 1 | You can build and install the Python package from the project's root directory. 2 | 3 | ```shell 4 | python3 -m pip install --verbose . 5 | ``` 6 | 7 | You can test the Python package: 8 | 9 | ```shell 10 | python3 -m pytest 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/extra_api.css: -------------------------------------------------------------------------------- 1 | .docblock { 2 | border-left: .05rem solid var(--md-primary-fg-color); 3 | } 4 | 5 | .docblock-desc { 6 | margin-left: 1em; 7 | } 8 | 9 | pre > code.decl { 10 | white-space: pre-wrap; 11 | } 12 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | libQASM is a library to parse cQASM programs, developed by QuTech. 2 | 3 | At the moment, libQASM only supports cQASM v3.0 programs 4 | (see [cQASM-spec](https://qutech-delft.github.io/cQASM-spec/latest/) for the language specification). 5 | 6 | It performs lexical, syntactic, and semantic analysis of an input program received via a file or a string. 7 | It produces one of the following results: 8 | 9 | - A syntactic or semantic AST (Abstract Syntax Tree) object. Depending on if we are parsing or analysing. 10 | - A list of parsing or analysing errors. In case the input program was malformed. 11 | - A JSON representation of either the AST or the list of errors. 12 | 13 | It can be used from: 14 | 15 | - C++ projects (as a [Conan package](https://conan.io/center/recipes/libqasm)). 16 | - Python projects (as a [Python package](https://pypi.org/project/libqasm/)). 17 | - Emscripten projects (via a Typescript frontend). 18 | 19 | Check out [QX simulator](https://github.com/QuTech-Delft/qx-simulator) 20 | and [OpenSquirrel](https://github.com/QuTech-Delft/OpenSquirrel) compiler 21 | for an example of use in a C++ and a Python project, respectively. 22 | -------------------------------------------------------------------------------- /docs/python_highlight.js: -------------------------------------------------------------------------------- 1 | document$.subscribe(() => { 2 | hljs.highlightAll(), 3 | { language: 'python' } 4 | }) 5 | -------------------------------------------------------------------------------- /docs/typescript_highlight.js: -------------------------------------------------------------------------------- 1 | document$.subscribe(() => { 2 | hljs.highlightAll(), 3 | { language: 'typescript' } 4 | }) 5 | -------------------------------------------------------------------------------- /docs/user-guide/cpp-user-guide.md: -------------------------------------------------------------------------------- 1 | libQASM can be requested as a Conan package from a `conanfile.py`: 2 | 3 | ``` 4 | def build_requirements(self): 5 | self.tool_requires("libqasm/1.2.0") 6 | def requirements(self): 7 | self.requires("libqasm/1.2.0") 8 | ``` 9 | 10 | And then linked against from a `CMakeLists.txt`: 11 | 12 | ``` 13 | target_link_libraries( PUBLIC libqasm::libqasm) 14 | ``` 15 | 16 | !!! note 17 | 18 | You will need to have `Java JRE` >= 11 installed in case Conan needs to build libQASM. 19 | 20 | And used from a C++ program: 21 | 22 | ```cpp 23 | #include "libqasm/v3x/cqasm_python.hpp" 24 | 25 | auto program = std::string{ R"( 26 | version 3.0 27 | qubit[2] q 28 | bit[2] b 29 | H q[0] 30 | CNOT q[0], q[1] 31 | b = measure q 32 | )" }; 33 | 34 | auto parse_result = V3xAnalyzer::parse_string(program); 35 | 36 | auto analyzer = V3xAnalyzer(); 37 | auto analysis_result = analyzer.analyze_string(program); 38 | ``` 39 | -------------------------------------------------------------------------------- /docs/user-guide/docker.md: -------------------------------------------------------------------------------- 1 | libQASM can be tested in a container with the bare minimum requirements. 2 | 3 | ```shell 4 | docker build . 5 | ``` 6 | 7 | !!! note 8 | The above might fail on Windows due to the `autocrlf` transformation that git does. 9 | If you are having trouble with this just create new clone of this repository using: 10 | 11 | ``` 12 | git clone --config core.autocrlf=input git@github.com:QuTech-Delft/libqasm.git 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/user-guide/emscripten-user-guide.md: -------------------------------------------------------------------------------- 1 | libQASM can be used from a web environment via a Typescript frontend. 2 | 3 | Emscripten API only allows to input a cQASM program via a string 4 | and always returns a JSON string output. 5 | 6 | ```typescript 7 | import { default as wrapper } from 'cqasm_emscripten.mjs'; 8 | 9 | wrapper().then(function(result: any) { 10 | let cqasm = new result["EmscriptenWrapper"]() 11 | let program = `version 3.0 12 | qubit[2] q 13 | bit[2] b 14 | H q[0] 15 | CNOT q[0], q[1] 16 | b = measure q` 17 | let output = cqasm.parse_string_to_json(program, "bell.cq") 18 | cqasm.delete() 19 | }).catch((error: any) => { 20 | console.error("unhandledRejection", error, "\n"); 21 | }); 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/user-guide/python-user-guide.md: -------------------------------------------------------------------------------- 1 | libQASM can be installed as a Python package: 2 | 3 | ```shell 4 | pip install libqasm 5 | ``` 6 | 7 | And then imported from a Python program: 8 | 9 | ```python 10 | from libqasm import Analyzer 11 | 12 | program = r''' 13 | version 3.0 14 | qubit[2] q 15 | bit[2] b 16 | H q[0] 17 | CNOT q[0], q[1] 18 | b = measure q 19 | ''' 20 | 21 | parse_result = Analyzer.parse_string(program, "bell.cq") 22 | 23 | analyzer = Analyzer() 24 | analysis_result = analyzer.analyze_string(program, "bell.cq") 25 | ``` 26 | -------------------------------------------------------------------------------- /docs/user-guide/user-guide.md: -------------------------------------------------------------------------------- 1 | libQASM can be used from: 2 | 3 | - C++ projects (as a [Conan package](https://conan.io/center/recipes/libqasm)). 4 | - Python projects (as a [Python package](https://pypi.org/project/libqasm/)). 5 | - Emscripten projects (via a Typescript frontend). 6 | - Docker. 7 | -------------------------------------------------------------------------------- /emscripten/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(emsdk) 2 | 3 | add_executable(${PROJECT_NAME}_emscripten 4 | "${CMAKE_CURRENT_SOURCE_DIR}/emscripten_wrapper.cpp" 5 | ) 6 | 7 | target_link_libraries(${PROJECT_NAME}_emscripten 8 | PRIVATE cqasm 9 | ) 10 | 11 | target_compile_options(${PROJECT_NAME}_emscripten 12 | PUBLIC -fwasm-exceptions -Os -sSTRICT 13 | ) 14 | 15 | # --no-entry is needed by -sSTRICT 16 | target_link_options(${PROJECT_NAME}_emscripten 17 | PUBLIC -lembind -fwasm-exceptions -Os --no-entry -sENVIRONMENT=web -sEXPORT_ES6=1 -sFILESYSTEM=0 -sMODULARIZE=1 -sSTRICT 18 | ) 19 | -------------------------------------------------------------------------------- /include/libqasm/annotations_constants.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace cqasm::annotations { 4 | 5 | static constexpr const char* unknown_file_name = ""; 6 | 7 | } // namespace cqasm::annotations 8 | -------------------------------------------------------------------------------- /include/libqasm/cqasm.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \dir 3 | * Contains the non-generated public header files for libqasm's v3x API. 4 | * 5 | * \file 6 | * Main include file for libqasm; this is what you should be including. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "libqasm/v3x/cqasm.hpp" 12 | -------------------------------------------------------------------------------- /include/libqasm/string_builder.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * This file only contains utility stuff on top of the abstract syntax tree 3 | * structure generated by \ref tree-gen based on "syntactic.tree". Refer to 4 | * the cqasm::syntactic namespace documentation for more information. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include "libqasm/tree.hpp" 13 | 14 | namespace cqasm::syntactic { 15 | 16 | /** 17 | * Special/temporary string builder node, used to build strings from fragments 18 | * and escape sequences while parsing. This is abstracted out of the AST; it 19 | * should never appear after parsing completes. 20 | */ 21 | struct StringBuilder : public cqasm::tree::Base { 22 | std::ostringstream stream; 23 | 24 | /** 25 | * Pushes a string fragment into the string. 26 | */ 27 | void push_string(const std::string& str); 28 | 29 | /** 30 | * Pushes an escape sequence into the string. 31 | */ 32 | void push_escape(const std::string& escape); 33 | }; 34 | 35 | } // namespace cqasm::syntactic 36 | -------------------------------------------------------------------------------- /include/libqasm/tree.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Wrapper for pulling parts of tree-gen's support library into libqasm. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "tree-annotatable.hpp" 8 | #include "tree-base.hpp" 9 | 10 | /** 11 | * Namespace for wrapping tree-gen's support library. 12 | */ 13 | namespace cqasm::tree { 14 | 15 | using signed_size_t = ::tree::signed_size_t; 16 | 17 | using Annotatable = ::tree::annotatable::Annotatable; 18 | using Base = ::tree::base::Base; 19 | 20 | template 21 | using Maybe = ::tree::base::Maybe; 22 | 23 | template 24 | using One = ::tree::base::One; 25 | 26 | template 27 | using Any = ::tree::base::Any; 28 | 29 | template 30 | using Many = ::tree::base::Many; 31 | 32 | template 33 | using Link = ::tree::base::Link; 34 | 35 | template 36 | using OptLink = ::tree::base::OptLink; 37 | 38 | /** 39 | * Constructs a One object, analogous to std::make_shared. 40 | */ 41 | template 42 | One make(Args... args) { 43 | return One(std::make_shared(args...)); 44 | } 45 | 46 | } // namespace cqasm::tree 47 | -------------------------------------------------------------------------------- /include/libqasm/utils.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Defines various utility functions. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | /** 10 | * Namespace for various utility functions. 11 | */ 12 | namespace cqasm::utils { 13 | 14 | /** 15 | * Makes a string lowercase. 16 | */ 17 | std::string to_lowercase(const std::string& name); 18 | 19 | /** 20 | * Case-insensitive string compare. 21 | */ 22 | bool equal_case_insensitive(const std::string& lhs, const std::string& rhs); 23 | 24 | /** 25 | * Encodes a string in URL format. 26 | */ 27 | std::string url_encode(const std::string& str); 28 | 29 | /** 30 | * Encodes a string in JSON format. 31 | */ 32 | std::string json_encode(const std::string& str); 33 | 34 | /** 35 | * Removes the triple quotes from a raw string. 36 | */ 37 | std::string remove_triple_quotes(const std::string& str); 38 | 39 | } // namespace cqasm::utils 40 | -------------------------------------------------------------------------------- /include/libqasm/v3x/antlr_custom_error_listener.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace cqasm::v3x::parser { 10 | 11 | class AntlrCustomErrorListener : public antlr4::BaseErrorListener { 12 | /** 13 | * Name of the file being parsed. 14 | */ 15 | std::optional file_name_; 16 | 17 | void syntaxError(antlr4::Recognizer* recognizer, antlr4::Token* offending_symbol, size_t line, 18 | size_t char_position_in_line, const std::string& msg, std::exception_ptr e) override; 19 | 20 | public: 21 | explicit AntlrCustomErrorListener(const std::optional& file_name); 22 | void syntaxError(size_t line, size_t char_position_in_line, const std::string& msg); 23 | }; 24 | 25 | } // namespace cqasm::v3x::parser 26 | -------------------------------------------------------------------------------- /include/libqasm/v3x/register_instructions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "libqasm/v3x/analyzer.hpp" 4 | 5 | namespace cqasm::v3x::instruction { 6 | 7 | /** 8 | * Registers the cQASM 3.0 instruction set. 9 | */ 10 | void register_instructions(analyzer::Analyzer* analyzer); 11 | 12 | } // namespace cqasm::v3x::instruction 13 | -------------------------------------------------------------------------------- /include/libqasm/v3x/scope.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "libqasm/tree.hpp" 4 | #include "libqasm/v3x/resolver.hpp" 5 | #include "libqasm/v3x/semantic_generated.hpp" 6 | 7 | namespace cqasm::v3x::analyzer { 8 | 9 | /** 10 | * Scope information. 11 | */ 12 | struct Scope { 13 | /** 14 | * The variables visible within this scope. 15 | */ 16 | resolver::VariableTable variable_table; 17 | 18 | /** 19 | * The list of function supported by the language, and that can be evaluated at compile time. 20 | */ 21 | resolver::ConstEvalCoreFunctionTable consteval_core_function_table; 22 | 23 | /** 24 | * The instructions visible within this scope. 25 | * Instructions have a case-sensitively matched name, 26 | * and a signature for the types of parameters they expect. 27 | */ 28 | resolver::InstructionTable instruction_table; 29 | 30 | /** 31 | * The block associated with this scope. 32 | */ 33 | tree::One block; 34 | 35 | /** 36 | * The list of variables declared in this scope. 37 | */ 38 | tree::Any variables; 39 | }; 40 | 41 | } // namespace cqasm::v3x::analyzer 42 | -------------------------------------------------------------------------------- /include/libqasm/v3x/semantic.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Defines the types for the cQASM \ref cqasm::v3x::semantic "semantic tree", 3 | * based on the classes from cqasm::tree. 4 | * 5 | * This file is currently just a link to the \ref v3x/semantic_generated.hpp "generated file", 6 | * aside from one forward declaration in \ref v3x/semantic_helper.hpp. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "libqasm/v3x/semantic_generated.hpp" 12 | #include "libqasm/v3x/semantic_helper.hpp" 13 | -------------------------------------------------------------------------------- /include/libqasm/v3x/semantic_helper.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Forward reference for tree::semantic::Variable, 3 | * so the values tree can use it (resolves circular dependency). 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace cqasm::v3x::semantic { 9 | 10 | // NOTE JvS: 11 | // This forward declaration is needed in order to allow the value tree to link to Variable nodes in the semantic tree. 12 | // It's possible to get rid of this kludge by merging the value (and type) trees into the semantic tree, 13 | // as probably should have been done initially, but a lot of refactoring would result. 14 | class Variable; 15 | class Function; 16 | 17 | } // namespace cqasm::v3x::semantic 18 | -------------------------------------------------------------------------------- /include/libqasm/v3x/syntactic.hpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Defines the types for the cQASM \ref cqasm::v3x::ast "abstract syntax tree", 3 | * based on the classes from cqasm::tree. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "libqasm/string_builder.hpp" 9 | #include "libqasm/v3x/syntactic_generated.hpp" 10 | -------------------------------------------------------------------------------- /include/libqasm/v3x/syntactic_analyzer_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "libqasm/v3x/CqasmParser.h" 6 | #include "libqasm/v3x/CqasmParserVisitor.h" 7 | #include "libqasm/v3x/syntactic.hpp" 8 | 9 | namespace antlr4 { 10 | class Token; 11 | } 12 | namespace cqasm::v3x::parser { 13 | class AntlrCustomErrorListener; 14 | } 15 | 16 | namespace cqasm::v3x::parser { 17 | 18 | class BaseSyntacticAnalyzer : public CqasmParserVisitor { 19 | public: 20 | virtual void addErrorListener(AntlrCustomErrorListener* error_listener) = 0; 21 | virtual void syntaxError(size_t line, size_t char_position_in_line, const std::string& text) const = 0; 22 | virtual void setNodeAnnotation(const syntactic::One& node, antlr4::Token* token) const = 0; 23 | virtual void expandNodeAnnotation(const syntactic::One& node, antlr4::Token* token) const = 0; 24 | virtual void copyNodeAnnotation( 25 | const syntactic::One& from, const syntactic::One& to) const = 0; 26 | }; 27 | 28 | } // namespace cqasm::v3x::parser 29 | -------------------------------------------------------------------------------- /include/libqasm/versioning.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace cqasm { 4 | 5 | static const char* version{ "1.2.0" }; 6 | static const char* release_year{ "2025" }; 7 | 8 | [[nodiscard]] [[maybe_unused]] static const char* get_version() { 9 | return version; 10 | } 11 | 12 | [[nodiscard]] [[maybe_unused]] static const char* get_release_year() { 13 | return release_year; 14 | } 15 | 16 | } // namespace cqasm 17 | -------------------------------------------------------------------------------- /mkdocs.yaml: -------------------------------------------------------------------------------- 1 | INHERIT: ./mkdocs-base.yaml 2 | 3 | extra: 4 | version: 5 | provider: mike 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libqasm", 3 | "version": "1.2.0", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/QuTech-Delft/libqasm.git" 7 | }, 8 | "files": [ 9 | "./build/Release/emscripten/cqasm_emscripten.js", 10 | "./build/Release/emscripten/cqasm_emscripten.wasm" 11 | ], 12 | "exports": { 13 | "initWrapper": "./build/Release/emscripten/cqasm_emscripten.js", 14 | "cqasm.wasm": "./build/Release/emscripten/cqasm_emscripten.wasm" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools", 4 | "swig" 5 | ] 6 | build-backend = "setuptools.build_meta" 7 | 8 | [tool.cibuildwheel] 9 | before-all = "uname -a" 10 | build-verbosity = 3 11 | skip = [ 12 | "cp36-*", "cp37-*", "cp38-*", 13 | "*i686*", "*ppc64le*", "*pypy*", "*s390x*", "*musllinux*", 14 | "pp*", 15 | "*-win32", 16 | ] 17 | test-requires = "pytest" 18 | test-command = "pytest {project}/test" 19 | 20 | [tool.cibuildwheel.linux] 21 | manylinux-x86_64-image = "manylinux_2_28" 22 | manylinux-aarch64-image = "manylinux_2_28" 23 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | testpaths = 3 | "test/v10/python" 4 | "test/v3x/python" 5 | python_files = test_*.py 6 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # Python bindings sources 2 | 3 | This directory contains everything to do with generating the Python bindings, aside from the `setup.py` file living in the root directory. 4 | 5 | File/directory list: 6 | 7 | - `CMakeLists.txt`: SWIG and the Python extension build are handled by CMake, so it can link everything together properly. 8 | Don't use this file directly. It is intended to be added by the root `CMakeLists.txt`, and only when the build is orchestrated by `setup.py`. 9 | 10 | - `libqasm`: represents the Python module excluding the extension. Any Python files in here will be included in the Python install. 11 | 12 | - `libqasm.i`: SWIG directives for the bindings. 13 | 14 | - `python_lib.py`: helper script for CMake to find the Python library to link against, because `FindPYTHON` often picks the wrong one, especially in virtual environments. -------------------------------------------------------------------------------- /python/libqasm.i: -------------------------------------------------------------------------------- 1 | /* libqasm.i */ 2 | %module libqasm 3 | 4 | %begin %{ 5 | #ifdef _MSC_VER 6 | #define SWIG_PYTHON_INTERPRETER_NO_DEBUG 7 | #endif 8 | %} 9 | 10 | %{ 11 | #include "libqasm/v3x/cqasm_python.hpp" 12 | %} 13 | 14 | %include "exception.i" 15 | %include "std_except.i" 16 | %include "std_iostream.i" 17 | %include "std_string.i" 18 | %include "std_vector.i" 19 | 20 | namespace std { 21 | %template(vectori) vector; 22 | %template(vectorui) vector; 23 | %template(vectorf) vector; 24 | %template(vectord) vector; 25 | %template(vectors) vector; 26 | } 27 | 28 | %exception { 29 | try { 30 | $action 31 | if (PyErr_Occurred()) SWIG_fail; 32 | } 33 | SWIG_CATCH_STDEXCEPT 34 | catch (...) { 35 | SWIG_exception(SWIG_RuntimeError, "Unknown exception"); 36 | } 37 | } 38 | 39 | %include "libqasm/v3x/cqasm_python.hpp" 40 | -------------------------------------------------------------------------------- /python/module/cqasm/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /python/module/cqasm/v3x/instruction.py: -------------------------------------------------------------------------------- 1 | import cqasm.v3x.types 2 | 3 | 4 | class Instruction(object): 5 | def __init__(self, name, types=None): 6 | super().__init__() 7 | self._name = str(name) 8 | if types is None: 9 | self._types = () 10 | else: 11 | for typ in types: 12 | if not isinstance(typ, cqasm.v3x.types.Node): 13 | raise TypeError('types must be an iterable of cqasm.v3x.types.Node if specified') 14 | self._types = tuple(types) 15 | 16 | @property 17 | def name(self): 18 | return self._name 19 | 20 | @property 21 | def types(self): 22 | return self._types 23 | 24 | def __str__(self): 25 | return '{}({})'.format(self._name, ', '.join(map(str, self._types))) 26 | 27 | 28 | class InstructionRef(object): 29 | def __init__(self, *args, **kwargs): 30 | if not args and not kwargs: 31 | self._data = None 32 | elif len(args) == 1 and not kwargs and (isinstance(args[0], Instruction) or args[0] is None): 33 | self._data = args[0] 34 | else: 35 | self._data = Instruction(*args, **kwargs) 36 | 37 | @property 38 | def data(self): 39 | return self._data 40 | 41 | def __str__(self): 42 | return 'unresolved' if self._data is None else str(self._data) 43 | -------------------------------------------------------------------------------- /python/module/libqasm/__init__.py: -------------------------------------------------------------------------------- 1 | # Author Imran Ashraf, Jeroen van Straten 2 | 3 | import os 4 | from sys import version_info 5 | 6 | 7 | # Before we can import the dynamic modules, we have to set the linker search path appropriately. 8 | ld_lib_path = os.environ.get('LD_LIBRARY_PATH', '') 9 | if ld_lib_path: 10 | ld_lib_path += ':' 11 | os.environ['LD_LIBRARY_PATH'] = ld_lib_path + os.path.dirname(__file__) 12 | del ld_lib_path, os 13 | 14 | # We only support Python 3 15 | if version_info[0] != 3: 16 | raise EnvironmentError( 17 | "sys.version_info refers does not refer to a version of Python 3. " 18 | "This is not permitted. " 19 | "sys.version_info = {}".format(version_info)) 20 | del version_info 21 | 22 | # Import the SWIG-generated module. 23 | from .libqasm import * 24 | 25 | # __all__ = [ init, schedule, compile ] 26 | -------------------------------------------------------------------------------- /python/python_lib.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import sysconfig 4 | 5 | name = 'python' + ''.join(map(str, sys.version_info[0:2])) 6 | debug = sys.argv[1].lower() == 'debug' 7 | 8 | lib_dir = os.path.join(os.path.dirname(sysconfig.get_paths()['include']), 'libs') 9 | 10 | options = [] 11 | for entry in os.listdir(lib_dir): 12 | entry = entry.lower() 13 | if not entry.startswith(name): 14 | continue 15 | if not entry.endswith('.lib'): 16 | continue 17 | s = entry.split('_', maxsplit=1) 18 | flags = s[1] if len(s) > 1 else '' 19 | entry_debug = 'd' in flags 20 | if debug != entry_debug: 21 | continue 22 | options.append(entry) 23 | 24 | if not options: 25 | print('PYTHON_LIBRARIES_NOTFOUND') 26 | else: 27 | # if there are multiple, no idea how to choose which. 28 | options.sort() 29 | print(os.path.join(lib_dir, options[0])) 30 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | mike==2.1.2 2 | mkdocs-material==9.6.5 3 | mkdocstrings==0.28.2 4 | pymdown-extensions==10.8.1 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/empty_raw_text_string/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | AsmDeclaration( 30 | backend_name: < 31 | Identifier( 32 | name: Backend 33 | ) 34 | > 35 | backend_code: 36 | annotations: [] 37 | ) 38 | ] 39 | ) 40 | > 41 | ) 42 | 43 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/empty_raw_text_string/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | asm(Backend) '''''' 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/empty_raw_text_string/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | AsmDeclaration( 13 | backend_name: Backend 14 | backend_code: 15 | annotations: [] 16 | ) 17 | ] 18 | ) 19 | > 20 | variables: [ 21 | Variable( 22 | name: q 23 | typ: < 24 | Qubit( 25 | size: 1 26 | ) 27 | > 28 | annotations: [] 29 | ) 30 | ] 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/invalid_backend_name/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..8: mismatched input '100' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/invalid_backend_name/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | asm(100) ''' 6 | // Backend code 7 | ''' 8 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/invalid_missing_end_triple_quote_raw_string/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:14..17: mismatched input ''''' expecting RAW_TEXT_STRING 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/invalid_missing_end_triple_quote_raw_string/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | asm(Backend) ''' a ' " {} () [] b 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/valid_multiline_raw_text_string/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | AsmDeclaration( 30 | backend_name: < 31 | Identifier( 32 | name: Backend 33 | ) 34 | > 35 | backend_code: cqasm::v3x::primitives::Str<< 36 | 37 | a ' " {} () [] b 38 | // This is a single line comment which ends on the newline. 39 | /* This is a multi- 40 | line comment block */ 41 | >> 42 | annotations: [] 43 | ) 44 | ] 45 | ) 46 | > 47 | ) 48 | 49 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/valid_multiline_raw_text_string/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | asm(Backend) ''' 6 | a ' " {} () [] b 7 | // This is a single line comment which ends on the newline. 8 | /* This is a multi- 9 | line comment block */ 10 | ''' 11 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/valid_multiline_raw_text_string/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | AsmDeclaration( 13 | backend_name: Backend 14 | backend_code: cqasm::v3x::primitives::Str<< 15 | 16 | a ' " {} () [] b 17 | // This is a single line comment which ends on the newline. 18 | /* This is a multi- 19 | line comment block */ 20 | >> 21 | annotations: [] 22 | ) 23 | ] 24 | ) 25 | > 26 | variables: [ 27 | Variable( 28 | name: q 29 | typ: < 30 | Qubit( 31 | size: 1 32 | ) 33 | > 34 | annotations: [] 35 | ) 36 | ] 37 | ) 38 | 39 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/valid_raw_text_string/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | AsmDeclaration( 30 | backend_name: < 31 | Identifier( 32 | name: Backend 33 | ) 34 | > 35 | backend_code: a ' " {} () [] b 36 | annotations: [] 37 | ) 38 | ] 39 | ) 40 | > 41 | ) 42 | 43 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/valid_raw_text_string/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | asm(Backend) ''' a ' " {} () [] b ''' 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/asm_declaration/valid_raw_text_string/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | AsmDeclaration( 13 | backend_name: Backend 14 | backend_code: a ' " {} () [] b 15 | annotations: [] 16 | ) 17 | ] 18 | ) 19 | > 20 | variables: [ 21 | Variable( 22 | name: q 23 | typ: < 24 | Qubit( 25 | size: 1 26 | ) 27 | > 28 | annotations: [] 29 | ) 30 | ] 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/5/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:1..8 30 | name: < 31 | Keyword( 32 | name: barrier 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | IntegerLiteral( # input.cq:5:9..10 39 | value: 5 40 | ) 41 | ] 42 | ) 43 | > 44 | parameters: < 45 | ExpressionList( 46 | items: [] 47 | ) 48 | > 49 | annotations: [] 50 | ) 51 | ] 52 | ) 53 | > 54 | ) 55 | 56 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/5/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | barrier 5 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/5/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..8: failed to resolve instruction 'barrier' with argument pack (int) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/no_operand/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:8..9: mismatched input '\n' expecting {'(', '+', '-', '~', '!', BOOLEAN_LITERAL, INTEGER_LITERAL, FLOAT_LITERAL, IDENTIFIER} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/no_operand/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | barrier 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:1..8 30 | name: < 31 | Keyword( 32 | name: barrier 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | Identifier( # input.cq:5:9..10 39 | name: q 40 | ) 41 | ] 42 | ) 43 | > 44 | parameters: < 45 | ExpressionList( 46 | items: [] 47 | ) 48 | > 49 | annotations: [] 50 | ) 51 | ] 52 | ) 53 | > 54 | ) 55 | 56 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | barrier q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | NonGateInstruction( 13 | instruction_ref: barrier(qubit) 14 | name: barrier 15 | operands: [ 16 | VariableRef( 17 | variable --> < 18 | Variable( 19 | name: q 20 | typ: < 21 | Qubit( 22 | size: 1 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | ) 29 | ] 30 | parameters: [] 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | > 36 | variables: [ 37 | Variable( 38 | name: q 39 | typ: < 40 | Qubit( 41 | size: 1 42 | ) 43 | > 44 | annotations: [] 45 | ) 46 | ] 47 | ) 48 | 49 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/barrier_instruction/q_range_0_4/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[9] q 4 | 5 | barrier q[0:4] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_0_b/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:8..9 12 | name: < 13 | Identifier( 14 | name: b 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..7 19 | name: < 20 | Keyword( 21 | name: bit 22 | ) 23 | > 24 | size: < 25 | IntegerLiteral( 26 | value: 0 27 | ) 28 | > 29 | ) 30 | > 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | > 36 | ) 37 | 38 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_0_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[0] b 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_0_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:8..9: found bit array of size <= 0 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_123abc/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:8..11: extraneous input 'abc' expecting ']' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_123abc/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[123abc] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:8..9: missing IDENTIFIER at '\n' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:9..10: mismatched input '1' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] 1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_3.14/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:9..13: mismatched input '3.14' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_3.14/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] 3.14 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:9..10 12 | name: < 13 | Identifier( 14 | name: b 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..8 19 | name: < 20 | Keyword( 21 | name: bit 22 | ) 23 | > 24 | size: < 25 | IntegerLiteral( 26 | value: 17 27 | ) 28 | > 29 | ) 30 | > 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | > 36 | ) 37 | 38 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] b 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [ 15 | Variable( 16 | name: b 17 | typ: < 18 | BitArray( 19 | size: 17 20 | ) 21 | > 22 | annotations: [] 23 | ) 24 | ] 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b0_b1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:12..14: extraneous input 'b1' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b0_b1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] b0 b1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b0_comma_b1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:11..12: mismatched input ',' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b0_comma_b1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] b0, b1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b__bit_array_of_17_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] b 4 | bit[17] b 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b__bit_array_of_17_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:9..10: trying to redeclare variable 'b' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b_at_0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:10..11: mismatched input '[' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_b_at_0/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] b[0] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_equal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:9..10: mismatched input '=' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_17_equal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[17] = 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_3.14/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..9: mismatched input '3.14' expecting INTEGER_LITERAL 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_3.14/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[3.14] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_b/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..6: mismatched input 'b' expecting INTEGER_LITERAL 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[b] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_equal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..6: mismatched input '=' expecting INTEGER_LITERAL 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_array_definition/bit_array_of_equal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit[=] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bbit_b/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..4 12 | gate: < 13 | Gate( # input.cq:3:1..4 14 | name: < 15 | Identifier( 16 | name: Bit 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | Identifier( # input.cq:3:5..6 32 | name: b 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bbit_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | Bit b 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bbit_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..4: couldn't find instruction 'Bit' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:4..5: missing IDENTIFIER at '\n' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..6: mismatched input '1' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit 1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_123abc/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..8: extraneous input '123' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_123abc/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit 123abc 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_3.14/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..9: mismatched input '3.14' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_3.14/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit 3.14 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:5..6 12 | name: < 13 | Identifier( 14 | name: b 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..4 19 | name: < 20 | Keyword( 21 | name: bit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | ] 30 | ) 31 | > 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit b 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [ 15 | Variable( 16 | name: b 17 | typ: < 18 | Bit( 19 | size: 1 20 | ) 21 | > 22 | annotations: [] 23 | ) 24 | ] 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b0_b1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:8..10: extraneous input 'b1' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b0_b1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit b0 b1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b0_comma_b1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:7..8: mismatched input ',' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b0_comma_b1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit b0, b1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b__bit_b/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:5..6 12 | name: < 13 | Identifier( 14 | name: b 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..4 19 | name: < 20 | Keyword( 21 | name: bit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | Variable( # input.cq:4:5..6 30 | name: < 31 | Identifier( 32 | name: b 33 | ) 34 | > 35 | typ: < 36 | Type( # input.cq:4:1..4 37 | name: < 38 | Keyword( 39 | name: bit 40 | ) 41 | > 42 | size: - 43 | ) 44 | > 45 | annotations: [] 46 | ) 47 | ] 48 | ) 49 | > 50 | ) 51 | 52 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b__bit_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit b 4 | bit b 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b__bit_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:5..6: trying to redeclare variable 'b' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b_at_0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:6..7: mismatched input '[' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_b_at_0/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit b[0] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_equal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..6: mismatched input '=' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/bit_definition/bit_equal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit = 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/eu_uppercase/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | Rx(EU) q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/eu_uppercase/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:4..6: failed to resolve variable 'EU' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/pi_uppercase/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | Rx(PI) q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/pi_uppercase/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:4..6: failed to resolve variable 'PI' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/q_uppercase/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | X Q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/q_uppercase/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:3..4: failed to resolve variable 'Q' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/qubit_all_uppercase/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..6 12 | gate: < 13 | Gate( # input.cq:3:1..6 14 | name: < 15 | Identifier( 16 | name: QUBIT 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | Identifier( # input.cq:3:7..8 32 | name: q 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/qubit_all_uppercase/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | QUBIT q 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/qubit_all_uppercase/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..6: couldn't find instruction 'QUBIT' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/qubit_camel_case/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..6 12 | gate: < 13 | Gate( # input.cq:3:1..6 14 | name: < 15 | Identifier( 16 | name: Qubit 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | Identifier( # input.cq:3:7..8 32 | name: q 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/qubit_camel_case/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | Qubit q 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/qubit_camel_case/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..6: couldn't find instruction 'Qubit' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/tau_uppercase/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | Rx(TAU) q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/tau_uppercase/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:4..7: failed to resolve variable 'TAU' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/version_all_uppercase/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:1..8: mismatched input 'VERSION' expecting {NEW_LINE, ';', 'version'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/version_all_uppercase/input.cq: -------------------------------------------------------------------------------- 1 | VERSION 3 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/version_camel_case/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:1..8: mismatched input 'Version' expecting {NEW_LINE, ';', 'version'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/version_camel_case/input.cq: -------------------------------------------------------------------------------- 1 | Version 3 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/x_lowercase/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | x q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/case_sensitiveness/x_lowercase/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:1..2: couldn't find instruction 'x' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | /* This is a multi- 4 | line comment block */ 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line_then_error/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..6: no viable alternative at input 'blah\n' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line_then_error/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | /* This is a multi- 4 | line comment block */ 5 | blah 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line_then_error/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..5: expression statement is not of function call type 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line_within_single_line/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line_within_single_line/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | // This is a single line comment /* This is a multi-line comment block */ which ends on the newline. 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/multi_line_within_single_line/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/open_multi_line_within_single_line/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/open_multi_line_within_single_line/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | // This is a single line comment /* This is an open multi-line comment block 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/open_multi_line_within_single_line/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/python_style_before_version/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:1: token recognition error at: '#' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/python_style_before_version/input.cq: -------------------------------------------------------------------------------- 1 | # blah 2 | version 3.0 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/python_style_single_line/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1: token recognition error at: '#' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/python_style_single_line/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | # This is a Python-style single line comment which ends on the newline. 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | // This is a single line comment which ends on the newline. 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_and_multi_line_before_version/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:4:12..15 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_and_multi_line_before_version/input.cq: -------------------------------------------------------------------------------- 1 | // blah 2 | /* foo 3 | * 4 | */version 3.0 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_and_multi_line_before_version/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_then_error/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:5: no viable alternative at input 'blah' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_then_error/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | // This is a single line comment which ends on the newline. 4 | blah -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_then_error/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:1..5: expression statement is not of function call type 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_within_multi_line/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_within_multi_line/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | 3 | /* This is a multi- 4 | // This is a single line comment which ends on the newline. 5 | line comment block */ 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/comments/single_line_within_multi_line/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/eof/error_right_before_eof/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":5,"character":9},"end":{"line":5,"character":9}},"message":"missing ']' at ''","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/eof/error_right_before_eof/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:9: missing ']' at '' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/eof/error_right_before_eof/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | 5 | h q[0, 4 -------------------------------------------------------------------------------- /res/v3x/tests/integration/eu_pi_tau/qubit_q__Rx_eu_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | Rx(eu) q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/eu_pi_tau/qubit_q__Rx_eu_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | GateInstruction( 13 | instruction_ref: Rx(qubit) 14 | gate: < 15 | Gate( 16 | name: Rx 17 | gate: - 18 | parameters: [ 19 | ConstFloat( 20 | value: 2.71828 21 | ) 22 | ] 23 | annotations: [] 24 | ) 25 | > 26 | operands: [ 27 | VariableRef( 28 | variable --> < 29 | Variable( 30 | name: q 31 | typ: < 32 | Qubit( 33 | size: 1 34 | ) 35 | > 36 | annotations: [] 37 | ) 38 | > 39 | ) 40 | ] 41 | annotations: [] 42 | ) 43 | ] 44 | ) 45 | > 46 | variables: [ 47 | Variable( 48 | name: q 49 | typ: < 50 | Qubit( 51 | size: 1 52 | ) 53 | > 54 | annotations: [] 55 | ) 56 | ] 57 | ) 58 | 59 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/eu_pi_tau/qubit_q__Rx_pi_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | Rx(pi) q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/eu_pi_tau/qubit_q__Rx_pi_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | GateInstruction( 13 | instruction_ref: Rx(qubit) 14 | gate: < 15 | Gate( 16 | name: Rx 17 | gate: - 18 | parameters: [ 19 | ConstFloat( 20 | value: 3.14159 21 | ) 22 | ] 23 | annotations: [] 24 | ) 25 | > 26 | operands: [ 27 | VariableRef( 28 | variable --> < 29 | Variable( 30 | name: q 31 | typ: < 32 | Qubit( 33 | size: 1 34 | ) 35 | > 36 | annotations: [] 37 | ) 38 | > 39 | ) 40 | ] 41 | annotations: [] 42 | ) 43 | ] 44 | ) 45 | > 46 | variables: [ 47 | Variable( 48 | name: q 49 | typ: < 50 | Qubit( 51 | size: 1 52 | ) 53 | > 54 | annotations: [] 55 | ) 56 | ] 57 | ) 58 | 59 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/eu_pi_tau/qubit_q__Rx_tau_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | Rx(tau) q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/eu_pi_tau/qubit_q__Rx_tau_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | GateInstruction( 13 | instruction_ref: Rx(qubit) 14 | gate: < 15 | Gate( 16 | name: Rx 17 | gate: - 18 | parameters: [ 19 | ConstFloat( 20 | value: 6.28319 21 | ) 22 | ] 23 | annotations: [] 24 | ) 25 | > 26 | operands: [ 27 | VariableRef( 28 | variable --> < 29 | Variable( 30 | name: q 31 | typ: < 32 | Qubit( 33 | size: 1 34 | ) 35 | > 36 | annotations: [] 37 | ) 38 | > 39 | ) 40 | ] 41 | annotations: [] 42 | ) 43 | ] 44 | ) 45 | > 46 | variables: [ 47 | Variable( 48 | name: q 49 | typ: < 50 | Qubit( 51 | size: 1 52 | ) 53 | > 54 | annotations: [] 55 | ) 56 | ] 57 | ) 58 | 59 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression/out_of_bounds_index/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[3] q 4 | X q[3] 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression/out_of_bounds_index/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:3..4: index 3 out of range (size 3) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression/out_of_range_float_literal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:3: value '1.79769313486231570e+309' is out of the FLOAT_LITERAL range 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression/out_of_range_float_literal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X 1.79769313486231570e+309 // biggest double is 1.79769313486231570e+308 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression/out_of_range_integer_literal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:3: value '18446744073709551616' is out of the INTEGER_LITERAL range 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression/out_of_range_integer_literal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X 18446744073709551616 // biggest 64-bit integer is 18446744073709551615 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression_list/bad_first_part/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:7:9..12: mismatched input 'abc' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression_list/bad_first_part/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[3] q 4 | 5 | H q[0] 6 | H q[1] 7 | CNOT 123abc, q[0] 8 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression_list/bad_second_part/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:7:15..18: extraneous input 'abc' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression_list/bad_second_part/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[3] q 4 | 5 | H q[0] 6 | H q[1] 7 | CNOT q[0], 123abc 8 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression_list/no_second_part/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:7:11..12: mismatched input '\n' expecting {'(', '+', '-', '~', '!', BOOLEAN_LITERAL, INTEGER_LITERAL, FLOAT_LITERAL, IDENTIFIER} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/expression_list/no_second_part/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[3] q 4 | 5 | H q[0] 6 | H q[1] 7 | CNOT q[0], 8 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/X_inv_q/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":3}},"message":"no viable alternative at input 'X.'","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/X_inv_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:2..3: no viable alternative at input 'X.' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/X_inv_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | X.inv q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/adj_X_q/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":5,"character":4},"end":{"line":5,"character":5}},"message":"no viable alternative at input 'adj.'","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/adj_X_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:4..5: no viable alternative at input 'adj.' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/adj_X_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | adj.X q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"version":{"Version":{"items":"3","source_location":"input.cq:1:9..10"}},"block":{"GlobalBlock":{"statements":[{"Variable":{"name":{"Identifier":{"name":"q"}},"typ":{"Type":{"name":{"Keyword":{"name":"qubit"}},"size":"-","source_location":"input.cq:3:1..6"}},"annotations":[],"source_location":"input.cq:3:7..8"}},{"GateInstruction":{"gate":{"Gate":{"name":{"Identifier":{"name":"ctrl"}},"gate":{"Gate":{"name":{"Identifier":{"name":"X"}},"gate":"-","parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:5:6..7"}},"parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:5:1..5"}},"operands":{"ExpressionList":{"items":[{"Identifier":{"name":"q","source_location":"input.cq:5:8..9"}}]}},"annotations":[],"source_location":"input.cq:5:1..5"}}]}}}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | ctrl.X q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":5,"character":1},"end":{"line":5,"character":5}},"message":"failed to resolve instruction '2q_X' with argument pack (qubit)","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..5: failed to resolve instruction '2q_X' with argument pack (qubit) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q_0_q_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[2] q 4 | 5 | ctrl.X q[0], q[1] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q_0_q_1/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"api_version":"3.0","version":{"Version":{"items":"3"}},"block":{"Block":{"statements":[{"GateInstruction":{"instruction_ref":"2q_X(qubit, qubit)","gate":{"Gate":{"name":"ctrl","gate":{"Gate":{"name":"X","gate":"-","parameters":[],"annotations":[]}},"parameters":[],"annotations":[]}},"operands":[{"IndexRef":{"variable":{"Variable":{"name":"q","typ":{"QubitArray":{"size":"2"}},"annotations":[]}},"indices":[{"ConstInt":{"value":"0"}}]}},{"IndexRef":{"variable":{"Variable":{"name":"q","typ":{"QubitArray":{"size":"2"}},"annotations":[]}},"indices":[{"ConstInt":{"value":"1"}}]}}],"annotations":[]}}]}},"variables":[{"Variable":{"name":"q","typ":{"QubitArray":{"size":"2"}},"annotations":[]}}]}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q_range_0_1/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"version":{"Version":{"items":"3","source_location":"input.cq:1:9..10"}},"block":{"GlobalBlock":{"statements":[{"Variable":{"name":{"Identifier":{"name":"q"}},"typ":{"Type":{"name":{"Keyword":{"name":"qubit"}},"size":{"IntegerLiteral":{"value":"2"}},"source_location":"input.cq:3:1..9"}},"annotations":[],"source_location":"input.cq:3:10..11"}},{"GateInstruction":{"gate":{"Gate":{"name":{"Identifier":{"name":"ctrl"}},"gate":{"Gate":{"name":{"Identifier":{"name":"X"}},"gate":"-","parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:5:6..7"}},"parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:5:1..5"}},"operands":{"ExpressionList":{"items":[{"Index":{"expr":{"Identifier":{"name":"q"}},"indices":{"IndexList":{"items":[{"IndexRange":{"first":{"IntegerLiteral":{"value":"0","source_location":"input.cq:5:10..11"}},"last":{"IntegerLiteral":{"value":"1","source_location":"input.cq:5:12..13"}}}}]}},"source_location":"input.cq:5:8..9"}}]}},"annotations":[],"source_location":"input.cq:5:1..5"}}]}}}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q_range_0_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[2] q 4 | 5 | ctrl.X q[0:1] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q_range_0_1/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":5,"character":1},"end":{"line":5,"character":5}},"message":"failed to resolve instruction '2q_X' with argument pack (qubit array)","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/ctrl_X_q_range_0_1/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..5: failed to resolve instruction '2q_X' with argument pack (qubit array) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_inv_X_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | inv.inv.X q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_inv_X_q/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"api_version":"3.0","version":{"Version":{"items":"3"}},"block":{"Block":{"statements":[{"GateInstruction":{"instruction_ref":"1q_X(qubit)","gate":{"Gate":{"name":"inv","gate":{"Gate":{"name":"inv","gate":{"Gate":{"name":"X","gate":"-","parameters":[],"annotations":[]}},"parameters":[],"annotations":[]}},"parameters":[],"annotations":[]}},"operands":[{"VariableRef":{"variable":{"Variable":{"name":"q","typ":{"Qubit":{"size":"1"}},"annotations":[]}}}}],"annotations":[]}}]}},"variables":[{"Variable":{"name":"q","typ":{"Qubit":{"size":"1"}},"annotations":[]}}]}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_reset/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":10}},"message":"mismatched input 'reset' expecting {'inv', 'pow', 'ctrl', IDENTIFIER}","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_reset/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:5..10: mismatched input 'reset' expecting {'inv', 'pow', 'ctrl', IDENTIFIER} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_reset/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | inv.reset 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_x_q/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"version":{"Version":{"items":"3","source_location":"input.cq:1:9..10"}},"block":{"GlobalBlock":{"statements":[{"Variable":{"name":{"Identifier":{"name":"q"}},"typ":{"Type":{"name":{"Keyword":{"name":"qubit"}},"size":"-","source_location":"input.cq:3:1..6"}},"annotations":[],"source_location":"input.cq:3:7..8"}},{"GateInstruction":{"gate":{"Gate":{"name":{"Identifier":{"name":"inv"}},"gate":{"Gate":{"name":{"Identifier":{"name":"x"}},"gate":"-","parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:5:5..6"}},"parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:5:1..4"}},"operands":{"ExpressionList":{"items":[{"Identifier":{"name":"q","source_location":"input.cq:5:7..8"}}]}},"annotations":[],"source_location":"input.cq:5:1..4"}}]}}}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_x_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | inv.x q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_x_q/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":5,"character":5},"end":{"line":5,"character":6}},"message":"couldn't find instruction 'x'","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/inv_x_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..6: couldn't find instruction 'x' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_2_X_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | pow(2).X q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_2_X_q/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"api_version":"3.0","version":{"Version":{"items":"3"}},"block":{"Block":{"statements":[{"GateInstruction":{"instruction_ref":"1q_X(qubit)","gate":{"Gate":{"name":"pow","gate":{"Gate":{"name":"X","gate":"-","parameters":[],"annotations":[]}},"parameters":[{"ConstFloat":{"value":"2"}}],"annotations":[]}},"operands":[{"VariableRef":{"variable":{"Variable":{"name":"q","typ":{"Qubit":{"size":"1"}},"annotations":[]}}}}],"annotations":[]}}]}},"variables":[{"Variable":{"name":"q","typ":{"Qubit":{"size":"1"}},"annotations":[]}}]}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_2_inv_ctrl_X_q_0_q_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:7..10: extraneous input 'inv' expecting '.' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_2_inv_ctrl_X_q_0_q_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[2] q 4 | 5 | pow(2)inv.ctrl.X q[0], q[1] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_2_inv_ctrl_X_q_0_q_1/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"errors":[{"range":{"start":{"line":5,"character":5},"end":{"line":5,"character":8}},"message":"trying to apply a gate modifier to a multi-qubit gate","severity":1,"relatedInformation":[{"location":{"uri":"file:///input.cq","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}}},"message":""}]},{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"message":"failed to resolve instruction 'pow' with argument pack (qubit, qubit)","severity":1}]} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_2_inv_ctrl_X_q_0_q_1/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..8: trying to apply a gate modifier to a multi-qubit gate 3 | Error: failed to resolve instruction 'pow' with argument pack (qubit, qubit) 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_b_X_q/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"version":{"Version":{"items":"3","source_location":"input.cq:1:9..10"}},"block":{"GlobalBlock":{"statements":[{"Variable":{"name":{"Identifier":{"name":"q"}},"typ":{"Type":{"name":{"Keyword":{"name":"qubit"}},"size":"-","source_location":"input.cq:3:1..6"}},"annotations":[],"source_location":"input.cq:3:7..8"}},{"Variable":{"name":{"Identifier":{"name":"b"}},"typ":{"Type":{"name":{"Keyword":{"name":"bit"}},"size":"-","source_location":"input.cq:4:1..4"}},"annotations":[],"source_location":"input.cq:4:5..6"}},{"GateInstruction":{"gate":{"Gate":{"name":{"Identifier":{"name":"pow"}},"gate":{"Gate":{"name":{"Identifier":{"name":"X"}},"gate":"-","parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:6:8..9"}},"parameters":{"ExpressionList":{"items":[{"Identifier":{"name":"b","source_location":"input.cq:6:5..6"}}]}},"annotations":[],"source_location":"input.cq:6:1..4"}},"operands":{"ExpressionList":{"items":[{"Identifier":{"name":"q","source_location":"input.cq:6:10..11"}}]}},"annotations":[],"source_location":"input.cq:6:1..4"}}]}}}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_b_X_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | bit b 5 | 6 | pow(b).X q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/gate_modifier/pow_b_X_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:6:1..4: failed to resolve 'pow' with parameter type (bit) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/5/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:1..5 30 | name: < 31 | Keyword( 32 | name: init 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | IntegerLiteral( # input.cq:5:6..7 39 | value: 5 40 | ) 41 | ] 42 | ) 43 | > 44 | parameters: < 45 | ExpressionList( 46 | items: [] 47 | ) 48 | > 49 | annotations: [] 50 | ) 51 | ] 52 | ) 53 | > 54 | ) 55 | 56 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/5/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | init 5 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/5/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..5: failed to resolve instruction 'init' with argument pack (int) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/no_operand/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..6: mismatched input '\n' expecting {'(', '+', '-', '~', '!', BOOLEAN_LITERAL, INTEGER_LITERAL, FLOAT_LITERAL, IDENTIFIER} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/no_operand/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | init 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:1..5 30 | name: < 31 | Keyword( 32 | name: init 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | Identifier( # input.cq:5:6..7 39 | name: q 40 | ) 41 | ] 42 | ) 43 | > 44 | parameters: < 45 | ExpressionList( 46 | items: [] 47 | ) 48 | > 49 | annotations: [] 50 | ) 51 | ] 52 | ) 53 | > 54 | ) 55 | 56 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | init q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | NonGateInstruction( 13 | instruction_ref: init(qubit) 14 | name: init 15 | operands: [ 16 | VariableRef( 17 | variable --> < 18 | Variable( 19 | name: q 20 | typ: < 21 | Qubit( 22 | size: 1 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | ) 29 | ] 30 | parameters: [] 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | > 36 | variables: [ 37 | Variable( 38 | name: q 39 | typ: < 40 | Qubit( 41 | size: 1 42 | ) 43 | > 44 | annotations: [] 45 | ) 46 | ] 47 | ) 48 | 49 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/init_instruction/q_range_0_4/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[9] q 4 | 5 | init q[0:4] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:2..3: no viable alternative at input 'X\n' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..2: expression statement is not of function call type 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..2 12 | gate: < 13 | Gate( # input.cq:3:1..2 14 | name: < 15 | Identifier( 16 | name: X 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | IntegerLiteral( # input.cq:3:3..4 32 | value: 1 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X 1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_1/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..2: failed to resolve instruction 'X' with argument pack (int) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_123abc/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:6..9: extraneous input 'abc' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_123abc/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X 123abc 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_3.14/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..2 12 | gate: < 13 | Gate( # input.cq:3:1..2 14 | name: < 15 | Identifier( 16 | name: X 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | FloatLiteral( # input.cq:3:3..7 32 | value: 3.14 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_3.14/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X 3.14 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_3.14/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..2: failed to resolve instruction 'X' with argument pack (float) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_q0/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X q[0] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_q0/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:3..4: failed to resolve variable 'q' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_v/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..2 12 | gate: < 13 | Gate( # input.cq:3:1..2 14 | name: < 15 | Identifier( 16 | name: X 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | Identifier( # input.cq:3:3..4 32 | name: v 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_v/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | X v 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/X_v/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:3..4: failed to resolve variable 'v' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/qubit_2__H_q_0__H_q_1__CNOT_q_0_q_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[2] q 4 | 5 | H q[0] 6 | H q[1] 7 | CNOT q[0], q[1] 8 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/qubit_q__X_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | X q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/qubit_q__X_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | GateInstruction( 13 | instruction_ref: X(qubit) 14 | gate: < 15 | Gate( 16 | name: X 17 | gate: - 18 | parameters: [] 19 | annotations: [] 20 | ) 21 | > 22 | operands: [ 23 | VariableRef( 24 | variable --> < 25 | Variable( 26 | name: q 27 | typ: < 28 | Qubit( 29 | size: 1 30 | ) 31 | > 32 | annotations: [] 33 | ) 34 | > 35 | ) 36 | ] 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | variables: [ 43 | Variable( 44 | name: q 45 | typ: < 46 | Qubit( 47 | size: 1 48 | ) 49 | > 50 | annotations: [] 51 | ) 52 | ] 53 | ) 54 | 55 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/v_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..2 12 | gate: < 13 | Gate( # input.cq:3:1..2 14 | name: < 15 | Identifier( 16 | name: v 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | IntegerLiteral( # input.cq:3:3..4 32 | value: 1 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/v_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | v 1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/instruction/v_1/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..2: couldn't find instruction 'v' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_3_q_to_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[3] q 4 | bit b 5 | 6 | b = measure q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_3_q_to_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:6:5..12: qubit and bit indices have different sizes 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_5_q_to_array_of_5_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[5] b 5 | 6 | b = measure q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_5_q_to_array_of_9_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[9] b 5 | 6 | b = measure q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_5_q_to_array_of_9_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:6:5..12: qubit and bit indices have different sizes 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_5_q_to_b_range_0_4/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[9] b 5 | 6 | b[0:4] = measure q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_5_q_to_b_range_2_6/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[9] b 5 | 6 | b[2:6] = measure q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_9_q_to_array_of_5_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[9] b 5 | 6 | b = measure q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/array_of_9_q_to_array_of_5_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:6:5..12: qubit and bit indices have different sizes 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/b_to_b/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:5..6 12 | name: < 13 | Identifier( 14 | name: b 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..4 19 | name: < 20 | Keyword( 21 | name: bit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:5..12 30 | name: < 31 | Keyword( 32 | name: measure 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | Identifier( # input.cq:5:1..2 39 | name: b 40 | ) 41 | Identifier( # input.cq:5:13..14 42 | name: b 43 | ) 44 | ] 45 | ) 46 | > 47 | parameters: < 48 | ExpressionList( 49 | items: [] 50 | ) 51 | > 52 | annotations: [] 53 | ) 54 | ] 55 | ) 56 | > 57 | ) 58 | 59 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/b_to_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit b 4 | 5 | b = measure b 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/b_to_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..12: failed to resolve instruction 'measure' with argument pack (bit, bit) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/b_to_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | bit b 5 | 6 | q = measure b 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/b_to_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:6:5..12: failed to resolve instruction 'measure' with argument pack (qubit, bit) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/bit_and_qubit/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | bit b 5 | 6 | b = measure q 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/no_bit/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:1..8: extraneous input 'measure' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/no_bit/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | measure q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/no_bit_no_qubit/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..8: no viable alternative at input '\n\nmeasure' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/no_bit_no_qubit/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | measure 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/no_qubit/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:12..13: mismatched input '\n' expecting {'(', '+', '-', '~', '!', BOOLEAN_LITERAL, INTEGER_LITERAL, FLOAT_LITERAL, IDENTIFIER} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/no_qubit/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | bit b 4 | 5 | b = measure 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q0_to_array_of_3_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q0 4 | bit[3] b 5 | 6 | b = measure q0 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q0_to_array_of_3_b/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:6:5..12: qubit and bit indices have different sizes 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q0_to_b_0/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q0 4 | bit[3] b 5 | 6 | b[0] = measure q0 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_0_to_b0/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[3] q 4 | bit b0 5 | 6 | b0 = measure q[0] 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_1_3_4_5_7_to_array_of_5_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[9] q 4 | bit[5] b 5 | 6 | b = measure q[1, 3, 4, 5, 7] 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_2_4_to_b_1_3/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[5] b 5 | 6 | b[1, 3] = measure q[2, 4] 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_2_4_to_b_range_1_2/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[5] b 5 | 6 | b[1:2] = measure q[2, 4] 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_range_0_4_to_array_of_5_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[9] q 4 | bit[5] b 5 | 6 | b = measure q[0:4] 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_range_2_6_to_array_of_5_b/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[9] q 4 | bit[5] b 5 | 6 | b = measure q[2:6] 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_range_3_4_to_b_1_3/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[5] q 4 | bit[5] b 5 | 6 | b[1, 3] = measure q[3:4] 7 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_to_5/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:5..12 30 | name: < 31 | Keyword( 32 | name: measure 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | IntegerLiteral( # input.cq:5:1..2 39 | value: 5 40 | ) 41 | Identifier( # input.cq:5:13..14 42 | name: q 43 | ) 44 | ] 45 | ) 46 | > 47 | parameters: < 48 | ExpressionList( 49 | items: [] 50 | ) 51 | > 52 | annotations: [] 53 | ) 54 | ] 55 | ) 56 | > 57 | ) 58 | 59 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_to_5/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | 5 = measure q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_to_5/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..12: failed to resolve instruction 'measure' with argument pack (int, qubit) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_to_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:5..12 30 | name: < 31 | Keyword( 32 | name: measure 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | Identifier( # input.cq:5:1..2 39 | name: q 40 | ) 41 | Identifier( # input.cq:5:13..14 42 | name: q 43 | ) 44 | ] 45 | ) 46 | > 47 | parameters: < 48 | ExpressionList( 49 | items: [] 50 | ) 51 | > 52 | annotations: [] 53 | ) 54 | ] 55 | ) 56 | > 57 | ) 58 | 59 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_to_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | q = measure q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/measure_instruction/q_to_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..12: failed to resolve instruction 'measure' with argument pack (qubit, qubit) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/qubit_newline_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:6..7: extraneous input '\n' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/qubit_newline_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit 4 | q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/version_3_newline_qubit_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | ] 30 | ) 31 | > 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/version_3_newline_qubit_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/version_3_newline_qubit_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [ 15 | Variable( 16 | name: q 17 | typ: < 18 | Qubit( 19 | size: 1 20 | ) 21 | > 22 | annotations: [] 23 | ) 24 | ] 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/version_3_semicolon_qubit_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:1:18..19 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:1:12..17 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | ] 30 | ) 31 | > 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/version_3_semicolon_qubit_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3; qubit q 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/newline_or_semicolon/version_3_semicolon_qubit_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [ 15 | Variable( 16 | name: q 17 | typ: < 18 | Qubit( 19 | size: 1 20 | ) 21 | > 22 | annotations: [] 23 | ) 24 | ] 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/bad_token_after_version/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:4..7: mismatched input 'abc' expecting '=' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/bad_token_after_version/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | 123abc 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/newlines_before_version/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:3:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/newlines_before_version/input.cq: -------------------------------------------------------------------------------- 1 | 2 | 3 | version 3.0 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/newlines_before_version/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/no_statement_separators_after_last_statement/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | qubit q 3 | X q -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/no_statement_separators_after_last_statement/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | GateInstruction( 13 | instruction_ref: X(qubit) 14 | gate: < 15 | Gate( 16 | name: X 17 | gate: - 18 | parameters: [] 19 | annotations: [] 20 | ) 21 | > 22 | operands: [ 23 | VariableRef( 24 | variable --> < 25 | Variable( 26 | name: q 27 | typ: < 28 | Qubit( 29 | size: 1 30 | ) 31 | > 32 | annotations: [] 33 | ) 34 | > 35 | ) 36 | ] 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | variables: [ 43 | Variable( 44 | name: q 45 | typ: < 46 | Qubit( 47 | size: 1 48 | ) 49 | > 50 | annotations: [] 51 | ) 52 | ] 53 | ) 54 | 55 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/no_statement_separators_after_version/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/no_statement_separators_after_version/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/no_statement_separators_after_version/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/statement_separators_after_statements/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | qubit q 3 | X q;; 4 | 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/statement_separators_after_statements/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | GateInstruction( 13 | instruction_ref: X(qubit) 14 | gate: < 15 | Gate( 16 | name: X 17 | gate: - 18 | parameters: [] 19 | annotations: [] 20 | ) 21 | > 22 | operands: [ 23 | VariableRef( 24 | variable --> < 25 | Variable( 26 | name: q 27 | typ: < 28 | Qubit( 29 | size: 1 30 | ) 31 | > 32 | annotations: [] 33 | ) 34 | > 35 | ) 36 | ] 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | variables: [ 43 | Variable( 44 | name: q 45 | typ: < 46 | Qubit( 47 | size: 1 48 | ) 49 | > 50 | annotations: [] 51 | ) 52 | ] 53 | ) 54 | 55 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/statement_separators_before_eof/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/statement_separators_before_eof/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0;; 2 | 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/statement_separators_before_eof/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/statement_separators_between_statements/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | qubit q;; 3 | 4 | X q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/program/statement_separators_between_statements/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | GateInstruction( 13 | instruction_ref: X(qubit) 14 | gate: < 15 | Gate( 16 | name: X 17 | gate: - 18 | parameters: [] 19 | annotations: [] 20 | ) 21 | > 22 | operands: [ 23 | VariableRef( 24 | variable --> < 25 | Variable( 26 | name: q 27 | typ: < 28 | Qubit( 29 | size: 1 30 | ) 31 | > 32 | annotations: [] 33 | ) 34 | > 35 | ) 36 | ] 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | variables: [ 43 | Variable( 44 | name: q 45 | typ: < 46 | Qubit( 47 | size: 1 48 | ) 49 | > 50 | annotations: [] 51 | ) 52 | ] 53 | ) 54 | 55 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_0_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:10..11 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..9 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: < 25 | IntegerLiteral( 26 | value: 0 27 | ) 28 | > 29 | ) 30 | > 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | > 36 | ) 37 | 38 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_0_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[0] q 4 | 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_0_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:10..11: found qubit array of size <= 0 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_123abc/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:10..13: extraneous input 'abc' expecting ']' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_123abc/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[123abc] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:10..11: missing IDENTIFIER at '\n' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:11..12: mismatched input '1' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] 1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_3.14/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:11..15: mismatched input '3.14' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_3.14/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] 3.14 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_equal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:11..12: mismatched input '=' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_equal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] = 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:11..12 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..10 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: < 25 | IntegerLiteral( 26 | value: 17 27 | ) 28 | > 29 | ) 30 | > 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | > 36 | ) 37 | 38 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] q 4 | 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [ 15 | Variable( 16 | name: q 17 | typ: < 18 | QubitArray( 19 | size: 17 20 | ) 21 | > 22 | annotations: [] 23 | ) 24 | ] 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q0_comma_q1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:13..14: mismatched input ',' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q0_comma_q1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] q0, q1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q0_q1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:14..16: extraneous input 'q1' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q0_q1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] q0 q1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q__qubit_array_of_17_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] q 4 | qubit[17] q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q__qubit_array_of_17_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:11..12: trying to redeclare variable 'q' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q_at_0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:12..13: mismatched input '[' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q_at_0/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[17] q[0] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_3.14_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:7..11: mismatched input '3.14' expecting INTEGER_LITERAL 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_3.14_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[3.14] q 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_equal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:7..8: mismatched input '=' expecting INTEGER_LITERAL 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_equal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[=] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:7..8: mismatched input 'q' expecting INTEGER_LITERAL 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_array_definition/qubit_array_of_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[q] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qqubit_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | GateInstruction( # input.cq:3:1..6 12 | gate: < 13 | Gate( # input.cq:3:1..6 14 | name: < 15 | Identifier( 16 | name: Qubit 17 | ) 18 | > 19 | gate: - 20 | parameters: < 21 | ExpressionList( 22 | items: [] 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | operands: < 29 | ExpressionList( 30 | items: [ 31 | Identifier( # input.cq:3:7..8 32 | name: q 33 | ) 34 | ] 35 | ) 36 | > 37 | annotations: [] 38 | ) 39 | ] 40 | ) 41 | > 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qqubit_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | Qubit q 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qqubit_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:1..6: couldn't find instruction 'Qubit' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:6..7: missing IDENTIFIER at '\n' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:7..8: mismatched input '1' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit 1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_123abc/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:7..10: extraneous input '123' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_123abc/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit 123abc 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_equal/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:7..8: mismatched input '=' expecting IDENTIFIER 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_equal/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit = 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | ] 30 | ) 31 | > 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [ 15 | Variable( 16 | name: q 17 | typ: < 18 | Qubit( 19 | size: 1 20 | ) 21 | > 22 | annotations: [] 23 | ) 24 | ] 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q0_comma_q1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:9..10: mismatched input ',' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q0_comma_q1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q0, q1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q0_q1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:10..12: extraneous input 'q1' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q0_q1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q0 q1 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q1__qubit_q2/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..9 12 | name: < 13 | Identifier( 14 | name: q1 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | Variable( # input.cq:4:7..9 30 | name: < 31 | Identifier( 32 | name: q2 33 | ) 34 | > 35 | typ: < 36 | Type( # input.cq:4:1..6 37 | name: < 38 | Keyword( 39 | name: qubit 40 | ) 41 | > 42 | size: - 43 | ) 44 | > 45 | annotations: [] 46 | ) 47 | ] 48 | ) 49 | > 50 | ) 51 | 52 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q1__qubit_q2/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q1 4 | qubit q2 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q1__qubit_q2/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [ 15 | Variable( 16 | name: q1 17 | typ: < 18 | Qubit( 19 | size: 1 20 | ) 21 | > 22 | annotations: [] 23 | ) 24 | Variable( 25 | name: q2 26 | typ: < 27 | Qubit( 28 | size: 1 29 | ) 30 | > 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q__qubit_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | Variable( # input.cq:4:7..8 30 | name: < 31 | Identifier( 32 | name: q 33 | ) 34 | > 35 | typ: < 36 | Type( # input.cq:4:1..6 37 | name: < 38 | Keyword( 39 | name: qubit 40 | ) 41 | > 42 | size: - 43 | ) 44 | > 45 | annotations: [] 46 | ) 47 | ] 48 | ) 49 | > 50 | ) 51 | 52 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q__qubit_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | qubit q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q__qubit_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:4:7..8: trying to redeclare variable 'q' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q_at_0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:3:8..9: mismatched input '[' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/qubit_definition/qubit_q_at_0/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q[0] 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/5/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:1..6 30 | name: < 31 | Keyword( 32 | name: reset 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | IntegerLiteral( # input.cq:5:7..8 39 | value: 5 40 | ) 41 | ] 42 | ) 43 | > 44 | parameters: < 45 | ExpressionList( 46 | items: [] 47 | ) 48 | > 49 | annotations: [] 50 | ) 51 | ] 52 | ) 53 | > 54 | ) 55 | 56 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/5/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | reset 5 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/5/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..6: failed to resolve instruction 'reset' with argument pack (int) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/no_operand/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:6..7: mismatched input '\n' expecting {'(', '+', '-', '~', '!', BOOLEAN_LITERAL, INTEGER_LITERAL, FLOAT_LITERAL, IDENTIFIER} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/no_operand/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | reset 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [ 11 | Variable( # input.cq:3:7..8 12 | name: < 13 | Identifier( 14 | name: q 15 | ) 16 | > 17 | typ: < 18 | Type( # input.cq:3:1..6 19 | name: < 20 | Keyword( 21 | name: qubit 22 | ) 23 | > 24 | size: - 25 | ) 26 | > 27 | annotations: [] 28 | ) 29 | NonGateInstruction( # input.cq:5:1..6 30 | name: < 31 | Keyword( 32 | name: reset 33 | ) 34 | > 35 | operands: < 36 | ExpressionList( 37 | items: [ 38 | Identifier( # input.cq:5:7..8 39 | name: q 40 | ) 41 | ] 42 | ) 43 | > 44 | parameters: < 45 | ExpressionList( 46 | items: [] 47 | ) 48 | > 49 | annotations: [] 50 | ) 51 | ] 52 | ) 53 | > 54 | ) 55 | 56 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | reset q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | NonGateInstruction( 13 | instruction_ref: reset(qubit) 14 | name: reset 15 | operands: [ 16 | VariableRef( 17 | variable --> < 18 | Variable( 19 | name: q 20 | typ: < 21 | Qubit( 22 | size: 1 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | ) 29 | ] 30 | parameters: [] 31 | annotations: [] 32 | ) 33 | ] 34 | ) 35 | > 36 | variables: [ 37 | Variable( 38 | name: q 39 | typ: < 40 | Qubit( 41 | size: 1 42 | ) 43 | > 44 | annotations: [] 45 | ) 46 | ] 47 | ) 48 | 49 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/reset_instruction/q_range_0_4/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[9] q 4 | 5 | reset q[0:4] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/sgmq/cnot_q_0_1_q_3_2/ast.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"version":{"Version":{"items":"3","source_location":"input.cq:1:9..10"}},"block":{"GlobalBlock":{"statements":[{"Variable":{"name":{"Identifier":{"name":"q"}},"typ":{"Type":{"name":{"Keyword":{"name":"qubit"}},"size":{"IntegerLiteral":{"value":"4"}},"source_location":"input.cq:3:1..9"}},"annotations":[],"source_location":"input.cq:3:10..11"}},{"GateInstruction":{"gate":{"Gate":{"name":{"Identifier":{"name":"CNOT"}},"gate":"-","parameters":{"ExpressionList":{"items":[]}},"annotations":[],"source_location":"input.cq:5:1..5"}},"operands":{"ExpressionList":{"items":[{"Index":{"expr":{"Identifier":{"name":"q"}},"indices":{"IndexList":{"items":[{"IndexItem":{"index":{"IntegerLiteral":{"value":"0","source_location":"input.cq:5:8..9"}}}},{"IndexItem":{"index":{"IntegerLiteral":{"value":"1","source_location":"input.cq:5:11..12"}}}}]}},"source_location":"input.cq:5:6..7"}},{"Index":{"expr":{"Identifier":{"name":"q"}},"indices":{"IndexList":{"items":[{"IndexItem":{"index":{"IntegerLiteral":{"value":"3","source_location":"input.cq:5:17..18"}}}},{"IndexItem":{"index":{"IntegerLiteral":{"value":"2","source_location":"input.cq:5:20..21"}}}}]}},"source_location":"input.cq:5:15..16"}}]}},"annotations":[],"source_location":"input.cq:5:1..5"}}]}}}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/sgmq/cnot_q_0_1_q_3_2/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[4] q 4 | 5 | CNOT q[0, 1], q[3, 2] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/sgmq/cnot_q_0_1_q_3_2/semantic.3.0.golden.json: -------------------------------------------------------------------------------- 1 | {"Program":{"api_version":"3.0","version":{"Version":{"items":"3"}},"block":{"Block":{"statements":[{"GateInstruction":{"instruction_ref":"CNOT(qubit array, qubit array)","gate":{"Gate":{"name":"CNOT","gate":"-","parameters":[],"annotations":[]}},"operands":[{"IndexRef":{"variable":{"Variable":{"name":"q","typ":{"QubitArray":{"size":"4"}},"annotations":[]}},"indices":[{"ConstInt":{"value":"0"}},{"ConstInt":{"value":"1"}}]}},{"IndexRef":{"variable":{"Variable":{"name":"q","typ":{"QubitArray":{"size":"4"}},"annotations":[]}},"indices":[{"ConstInt":{"value":"3"}},{"ConstInt":{"value":"2"}}]}}],"annotations":[]}}]}},"variables":[{"Variable":{"name":"q","typ":{"QubitArray":{"size":"4"}},"annotations":[]}}]}} -------------------------------------------------------------------------------- /res/v3x/tests/integration/sgmq/cnot_q_0_q_3_2/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[4] q 4 | 5 | CNOT q[0], q[3, 2] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/sgmq/cnot_q_0_q_3_2/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..5: qubit operands indices have different sizes 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/empty/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:1: mismatched input '' expecting {NEW_LINE, ';', 'version'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/empty/input.cq: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuTech-Delft/libqasm/bd7931f4e3f6b3d54502b91566736b78d35f88b4/res/v3x/tests/integration/version/empty/input.cq -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/instruction_and_version_3.0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:1..6: mismatched input 'qubit' expecting {NEW_LINE, ';', 'version'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/instruction_and_version_3.0/input.cq: -------------------------------------------------------------------------------- 1 | qubit q 2 | 3 | x q 4 | 5 | version 3.0 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/instruction_called_version/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:9: token recognition error at: 'q' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/instruction_called_version/input.cq: -------------------------------------------------------------------------------- 1 | version q[1:6], 3.14159 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/no_version_and_instruction/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:1..6: mismatched input 'qubit' expecting {NEW_LINE, ';', 'version'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/no_version_and_instruction/input.cq: -------------------------------------------------------------------------------- 1 | qubit q 2 | 3 | x q 4 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_1.0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 1.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_1.0/input.cq: -------------------------------------------------------------------------------- 1 | version 1.0 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_1.0/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:9..12: the only cQASM version supported is 3.0, but the cQASM file is version 1.0 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_2.0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 2.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_2.0/input.cq: -------------------------------------------------------------------------------- 1 | version 2.0 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_2.0/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:9..12: the only cQASM version supported is 3.0, but the cQASM file is version 2.0 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3.0/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..12 5 | items: 3.0 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3.0/input.cq: -------------------------------------------------------------------------------- 1 | version 3.0 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3.0/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3.0 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3.2.1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:12..14: extraneous input '.1' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3.2.1/input.cq: -------------------------------------------------------------------------------- 1 | version 3.2.1 -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..10 5 | items: 3 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [] 12 | ) 13 | > 14 | variables: [] 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_30.20/ast.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | version: < 4 | Version( # input.cq:1:9..14 5 | items: 30.20 6 | ) 7 | > 8 | block: < 9 | GlobalBlock( 10 | statements: [] 11 | ) 12 | > 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_30.20/input.cq: -------------------------------------------------------------------------------- 1 | version 30.20 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_30.20/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:9..14: the only cQASM version supported is 3.0, but the cQASM file is version 30.20 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3__version_3__qubit_q/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:2:1..8: no viable alternative at input '\nversion' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3__version_3__qubit_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | version 3 3 | 4 | qubit q 5 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3_dot/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:10..11: extraneous input '.' expecting {, NEW_LINE, ';'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_3_dot/input.cq: -------------------------------------------------------------------------------- 1 | version 3. 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_no_number/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:8: missing VERSION_NUMBER at '' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/version_no_number/input.cq: -------------------------------------------------------------------------------- 1 | version -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/vrsion/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:1:1..7: mismatched input 'vrsion' expecting {NEW_LINE, ';', 'version'} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/version/vrsion/input.cq: -------------------------------------------------------------------------------- 1 | vrsion 3.0 2 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:5..6: mismatched input '\n' expecting '(' 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | wait 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_0_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | wait(0) q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_0_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | NonGateInstruction( 13 | instruction_ref: wait(qubit) 14 | name: wait 15 | operands: [ 16 | VariableRef( 17 | variable --> < 18 | Variable( 19 | name: q 20 | typ: < 21 | Qubit( 22 | size: 1 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | ) 29 | ] 30 | parameters: [ 31 | ConstInt( 32 | value: 0 33 | ) 34 | ] 35 | annotations: [] 36 | ) 37 | ] 38 | ) 39 | > 40 | variables: [ 41 | Variable( 42 | name: q 43 | typ: < 44 | Qubit( 45 | size: 1 46 | ) 47 | > 48 | annotations: [] 49 | ) 50 | ] 51 | ) 52 | 53 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_1.5_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | wait(1.5) q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_1.5_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:1..5: failed to resolve 'wait' with parameter type (float) 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_1/ast.golden.txt: -------------------------------------------------------------------------------- 1 | ERROR 2 | Error at input.cq:5:8..9: mismatched input '\n' expecting {'(', '+', '-', '~', '!', BOOLEAN_LITERAL, INTEGER_LITERAL, FLOAT_LITERAL, IDENTIFIER} 3 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_1/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | wait(1) 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_2_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | wait(2) q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_2_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | NonGateInstruction( 13 | instruction_ref: wait(qubit) 14 | name: wait 15 | operands: [ 16 | VariableRef( 17 | variable --> < 18 | Variable( 19 | name: q 20 | typ: < 21 | Qubit( 22 | size: 1 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | ) 29 | ] 30 | parameters: [ 31 | ConstInt( 32 | value: 2 33 | ) 34 | ] 35 | annotations: [] 36 | ) 37 | ] 38 | ) 39 | > 40 | variables: [ 41 | Variable( 42 | name: q 43 | typ: < 44 | Qubit( 45 | size: 1 46 | ) 47 | > 48 | annotations: [] 49 | ) 50 | ] 51 | ) 52 | 53 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_2_q_range_0_4/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit[9] q 4 | 5 | wait(2) q[0:4] 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_m1_q/input.cq: -------------------------------------------------------------------------------- 1 | version 3 2 | 3 | qubit q 4 | 5 | wait(-1) q 6 | -------------------------------------------------------------------------------- /res/v3x/tests/integration/wait_instruction/wait_m1_q/semantic.3.0.golden.txt: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | Program( 3 | api_version: 3.0 4 | version: < 5 | Version( 6 | items: 3 7 | ) 8 | > 9 | block: < 10 | Block( 11 | statements: [ 12 | NonGateInstruction( 13 | instruction_ref: wait(qubit) 14 | name: wait 15 | operands: [ 16 | VariableRef( 17 | variable --> < 18 | Variable( 19 | name: q 20 | typ: < 21 | Qubit( 22 | size: 1 23 | ) 24 | > 25 | annotations: [] 26 | ) 27 | > 28 | ) 29 | ] 30 | parameters: [ 31 | ConstInt( 32 | value: -1 33 | ) 34 | ] 35 | annotations: [] 36 | ) 37 | ] 38 | ) 39 | > 40 | variables: [ 41 | Variable( 42 | name: q 43 | typ: < 44 | Qubit( 45 | size: 1 46 | ) 47 | > 48 | annotations: [] 49 | ) 50 | ] 51 | ) 52 | 53 | -------------------------------------------------------------------------------- /scripts/python/mkdocstrings_handlers/cpp/templates/README: -------------------------------------------------------------------------------- 1 | mkdocstrings requires a handler to have a templates directory. -------------------------------------------------------------------------------- /scripts/python/mkdocstrings_handlers/emscripten/templates/README: -------------------------------------------------------------------------------- 1 | mkdocstrings requires a handler to have a templates directory. -------------------------------------------------------------------------------- /scripts/python/mkdocstrings_handlers/python/templates/README: -------------------------------------------------------------------------------- 1 | mkdocstrings requires a handler to have a templates directory. -------------------------------------------------------------------------------- /src/string_builder.cpp: -------------------------------------------------------------------------------- 1 | /** \file 2 | * Implementation for \ref include/libqasm/string_builder.hpp "libqasm/string_builder.hpp". 3 | */ 4 | 5 | #include "libqasm/string_builder.hpp" 6 | 7 | namespace cqasm::syntactic { 8 | 9 | /** 10 | * Pushes a string fragment into the string. 11 | */ 12 | void StringBuilder::push_string(const std::string& str) { 13 | stream << str; 14 | } 15 | 16 | /** 17 | * Pushes an escape sequence into the string. 18 | */ 19 | void StringBuilder::push_escape(const std::string& escape) { 20 | if (escape == "\\t") { 21 | stream << '\t'; 22 | } else if (escape == "\\n") { 23 | stream << '\n'; 24 | } else if (escape == "\\r") { 25 | stream << '\r'; 26 | } else if (escape == "\\'") { 27 | stream << '\''; 28 | } else if (escape == "\\\"") { 29 | stream << '\"'; 30 | } else if (escape == "\\\\") { 31 | stream << '\\'; 32 | } else { 33 | stream << escape; 34 | } 35 | } 36 | 37 | } // namespace cqasm::syntactic 38 | -------------------------------------------------------------------------------- /src/v3x/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # List of non-generated sources. 2 | set(CQASM_V3X_SOURCES 3 | "${CMAKE_CURRENT_SOURCE_DIR}/analysis_result.cpp" 4 | "${CMAKE_CURRENT_SOURCE_DIR}/analyzer.cpp" 5 | "${CMAKE_CURRENT_SOURCE_DIR}/antlr_custom_error_listener.cpp" 6 | "${CMAKE_CURRENT_SOURCE_DIR}/antlr_scanner.cpp" 7 | "${CMAKE_CURRENT_SOURCE_DIR}/core_function.cpp" 8 | "${CMAKE_CURRENT_SOURCE_DIR}/cqasm.cpp" 9 | "${CMAKE_CURRENT_SOURCE_DIR}/cqasm_python.cpp" 10 | "${CMAKE_CURRENT_SOURCE_DIR}/instruction.cpp" 11 | "${CMAKE_CURRENT_SOURCE_DIR}/instruction_set.cpp" 12 | "${CMAKE_CURRENT_SOURCE_DIR}/parse_helper.cpp" 13 | "${CMAKE_CURRENT_SOURCE_DIR}/parse_result.cpp" 14 | "${CMAKE_CURRENT_SOURCE_DIR}/primitives.cpp" 15 | "${CMAKE_CURRENT_SOURCE_DIR}/register_consteval_core_functions.cpp" 16 | "${CMAKE_CURRENT_SOURCE_DIR}/register_instructions.cpp" 17 | "${CMAKE_CURRENT_SOURCE_DIR}/resolver.cpp" 18 | "${CMAKE_CURRENT_SOURCE_DIR}/semantic_analyzer.cpp" 19 | "${CMAKE_CURRENT_SOURCE_DIR}/syntactic_analyzer.cpp" 20 | "${CMAKE_CURRENT_SOURCE_DIR}/types.cpp" 21 | "${CMAKE_CURRENT_SOURCE_DIR}/values.cpp" 22 | PARENT_SCOPE 23 | ) 24 | -------------------------------------------------------------------------------- /src/v3x/analysis_result.cpp: -------------------------------------------------------------------------------- 1 | #include "libqasm/v3x/analysis_result.hpp" 2 | 3 | #include 4 | 5 | #include "libqasm/result.hpp" 6 | 7 | namespace cqasm::v3x::analyzer { 8 | 9 | /** 10 | * "Unwraps" the result (as you would in Rust) to get the program node or an exception. 11 | * The exception is always an AnalysisFailed, deriving from std::runtime_error. 12 | * The actual error messages are in this case first written to the given output stream, defaulting to stderr. 13 | */ 14 | Root AnalysisResult::unwrap(std::ostream& out) const { 15 | if (errors.empty()) { 16 | return root; 17 | } 18 | out << fmt::format("{}", fmt::join(errors, "\n")); 19 | throw AnalysisFailed(); 20 | } 21 | 22 | /** 23 | * Returns a vector of strings, of which the first is reserved for the CBOR serialization of the v3.x semantic AST. 24 | * Any additional strings represent error messages. 25 | * Notice that the AST and error messages won't be available at the same time. 26 | */ 27 | std::vector AnalysisResult::to_strings() const { 28 | return cqasm::result::to_strings(*this); 29 | } 30 | 31 | /** 32 | * Returns a string with a JSON representation of an AnalysisResult. 33 | */ 34 | std::string AnalysisResult::to_json() const { 35 | return cqasm::result::to_json(*this); 36 | } 37 | 38 | } // namespace cqasm::v3x::analyzer 39 | -------------------------------------------------------------------------------- /src/v3x/parse_result.cpp: -------------------------------------------------------------------------------- 1 | #include "libqasm/v3x/parse_result.hpp" 2 | 3 | #include "libqasm/result.hpp" 4 | 5 | namespace cqasm::v3x::parser { 6 | 7 | /** 8 | * Returns a vector of strings, of which the first is reserved for the CBOR serialization of the v3.x syntactic AST. 9 | * Any additional strings represent error messages. 10 | * Notice that the AST and error messages won't be available at the same time. 11 | */ 12 | std::vector ParseResult::to_strings() const { 13 | return cqasm::result::to_strings(*this); 14 | } 15 | 16 | /** 17 | * Returns a string with a JSON representation of a ParseResult. 18 | */ 19 | std::string ParseResult::to_json() const { 20 | return cqasm::result::to_json(*this); 21 | } 22 | 23 | } // namespace cqasm::v3x::parser 24 | -------------------------------------------------------------------------------- /src/v3x/types.tree: -------------------------------------------------------------------------------- 1 | # Implementation for the various classes representing the types of values available in cQASM 3.0 2 | source 3 | 4 | # Header file for the various classes representing the types of values available in cQASM 3.0 5 | header "libqasm/v3x/types_generated.hpp" 6 | 7 | // Include tree base classes. 8 | include "libqasm/tree.hpp" 9 | tree_namespace cqasm::tree 10 | 11 | // Include primitive types. 12 | include "libqasm/v3x/primitives.hpp" 13 | import cqasm.v3x.primitives 14 | 15 | // Initialization function to use to construct default values for the tree base classes and primitives 16 | initialize_function cqasm::v3x::primitives::initialize 17 | serdes_functions cqasm::v3x::primitives::serialize cqasm::v3x::primitives::deserialize 18 | 19 | 20 | # Namespace for the various classes representing the types of values available in cQASM 3.0 21 | namespace cqasm 22 | namespace v3x 23 | namespace types 24 | 25 | type_base { 26 | size: cqasm::v3x::primitives::Int; 27 | 28 | # Type of a boolean. 29 | bool {} 30 | 31 | # Type of an integer (signed 64-bit). 32 | int {} 33 | 34 | # Type of a float number (IEEE double). 35 | float {} 36 | 37 | bit {} 38 | qubit {} 39 | 40 | bit_array {} 41 | qubit_array {} 42 | } 43 | -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "v3x/cpp/integration_test.hpp" 6 | 7 | int main_impl(int argc, char** argv, std::ostream&) { 8 | ::testing::InitGoogleMock(&argc, argv); 9 | 10 | cqasm::v3x::test::register_tests(); 11 | 12 | return RUN_ALL_TESTS(); 13 | } 14 | 15 | int main(int argc, char** argv) { 16 | return main_impl(argc, argv, std::cout); 17 | } 18 | -------------------------------------------------------------------------------- /test/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.hpp" 2 | 3 | #include // ifstream, ofstream 4 | #include // istreambuf_iterator 5 | 6 | namespace cqasm::test { 7 | 8 | namespace fs = std::filesystem; 9 | 10 | /** 11 | * Reads the given file into the given string buffer and 12 | * returns true if it exists, 13 | * otherwise do nothing with the buffer and return false. 14 | */ 15 | bool read_file(const fs::path& file_path, std::string& output) { 16 | std::ifstream ifs(file_path); 17 | if (!ifs.is_open()) { 18 | return false; 19 | } 20 | output.clear(); 21 | ifs.seekg(0, std::ios::end); 22 | output.reserve(ifs.tellg()); 23 | ifs.seekg(0, std::ios::beg); 24 | output.assign(std::istreambuf_iterator(ifs), std::istreambuf_iterator()); 25 | return true; 26 | } 27 | 28 | /** 29 | * Overwrites or creates the given file with the given string. 30 | */ 31 | void write_file(const fs::path& file_path, const std::string& input) { 32 | std::ofstream stream(file_path, std::ios::binary | std::ios::out); // always write LF, i.e., avoid CR+LF in Windows 33 | stream << input; 34 | } 35 | 36 | } // namespace cqasm::test 37 | -------------------------------------------------------------------------------- /test/utils.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace cqasm::test { 5 | 6 | namespace fs = std::filesystem; 7 | 8 | /** 9 | * Reads the given file into the given string buffer and 10 | * returns true if it exists, 11 | * otherwise do nothing with the buffer and return false. 12 | */ 13 | bool read_file(const fs::path& file_path, std::string& output); 14 | 15 | /** 16 | * Overwrites or creates the given file with the given string. 17 | */ 18 | void write_file(const fs::path& file_path, const std::string& input); 19 | 20 | } // namespace cqasm::test 21 | -------------------------------------------------------------------------------- /test/v3x/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cpp) 2 | -------------------------------------------------------------------------------- /test/v3x/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuTech-Delft/libqasm/bd7931f4e3f6b3d54502b91566736b78d35f88b4/test/v3x/__init__.py -------------------------------------------------------------------------------- /test/v3x/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME}_test PRIVATE 2 | "${CMAKE_CURRENT_SOURCE_DIR}/integration_test.cpp" 3 | "${CMAKE_CURRENT_SOURCE_DIR}/matcher_values.cpp" 4 | "${CMAKE_CURRENT_SOURCE_DIR}/test_analyzer.cpp" 5 | "${CMAKE_CURRENT_SOURCE_DIR}/test_functions.cpp" 6 | "${CMAKE_CURRENT_SOURCE_DIR}/test_instruction_set.cpp" 7 | "${CMAKE_CURRENT_SOURCE_DIR}/test_parse_helper.cpp" 8 | "${CMAKE_CURRENT_SOURCE_DIR}/test_semantic_analyzer.cpp" 9 | "${CMAKE_CURRENT_SOURCE_DIR}/test_values.cpp" 10 | ) 11 | -------------------------------------------------------------------------------- /test/v3x/cpp/integration_test.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace cqasm::v3x::test { 4 | 5 | void register_tests(); 6 | 7 | } // namespace cqasm::v3x::test 8 | -------------------------------------------------------------------------------- /test/v3x/cpp/matcher_values.cpp: -------------------------------------------------------------------------------- 1 | #include "matcher_values.hpp" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "libqasm/v3x/semantic_generated.hpp" 8 | 9 | namespace cqasm::v3x::values { 10 | 11 | ValuesEqMatcher::ValuesEqMatcher(const Values& expected_value) 12 | : expected_value_(expected_value) {} 13 | 14 | bool ValuesEqMatcher::MatchAndExplain(const Values& args, std::ostream* /* os */) const { 15 | return args.equals(expected_value_); 16 | } 17 | 18 | void ValuesEqMatcher::DescribeTo(std::ostream* os) const { 19 | *os << "contains values equal to the expected"; 20 | } 21 | 22 | void ValuesEqMatcher::DescribeNegationTo(std::ostream* os) const { 23 | *os << "does not contain values equal to the expected"; 24 | } 25 | 26 | ::testing::Matcher ValuesEq(const values::Values& expected_value) { 27 | return ValuesEqMatcher(expected_value); 28 | } 29 | 30 | } // namespace cqasm::v3x::values 31 | -------------------------------------------------------------------------------- /test/v3x/cpp/matcher_values.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include //ostream 6 | 7 | #include "libqasm/v3x/values.hpp" 8 | 9 | namespace cqasm::v3x::values { 10 | 11 | class ValuesEqMatcher { 12 | public: 13 | using is_gtest_matcher = void; 14 | 15 | ValuesEqMatcher(const values::Values& expected_value); 16 | bool MatchAndExplain(const values::Values& args, std::ostream* os) const; 17 | void DescribeTo(std::ostream* os) const; 18 | void DescribeNegationTo(std::ostream* os) const; 19 | 20 | private: 21 | const values::Values& expected_value_; 22 | }; 23 | 24 | ::testing::Matcher ValuesEq(const values::Values& expected_value); 25 | 26 | } // namespace cqasm::v3x::values 27 | -------------------------------------------------------------------------------- /test/v3x/cpp/mock_analyzer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "libqasm/v3x/analyzer.hpp" 8 | #include "libqasm/v3x/values.hpp" 9 | 10 | namespace cqasm::v3x::analyzer { 11 | 12 | struct MockAnalyzer : public Analyzer { 13 | MOCK_METHOD((AnalysisResult), analyze, (const parser::ParseResult& parse_result)); 14 | MOCK_METHOD((values::Value), resolve_function, (const std::string& name, const values::Values& args), (const)); 15 | 16 | [[nodiscard]] std::list& scope_stack() { return scope_stack_; } 17 | 18 | [[nodiscard]] Scope& global_scope() { return Analyzer::global_scope(); } 19 | [[nodiscard]] Scope& current_scope() { return Analyzer::current_scope(); } 20 | [[nodiscard]] tree::One current_block() { return Analyzer::current_block(); } 21 | [[nodiscard]] tree::Any& current_variables() { return Analyzer::current_variables(); } 22 | 23 | [[nodiscard]] const Scope& global_scope() const { return Analyzer::global_scope(); } 24 | [[nodiscard]] const Scope& current_scope() const { return Analyzer::current_scope(); } 25 | [[nodiscard]] const tree::Any& current_variables() const { 26 | return Analyzer::current_variables(); 27 | } 28 | }; 29 | 30 | } // namespace cqasm::v3x::analyzer 31 | -------------------------------------------------------------------------------- /test/v3x/cpp/mock_scanner_adaptor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "libqasm/v3x/parse_helper.hpp" 8 | #include "libqasm/v3x/parse_result.hpp" 9 | 10 | namespace cqasm::v3x::parser { 11 | 12 | struct MockScannerAdaptor : public ScannerAdaptor { 13 | MOCK_METHOD((ParseResult), parse, (), (override)); 14 | }; 15 | 16 | } // namespace cqasm::v3x::parser 17 | -------------------------------------------------------------------------------- /test/v3x/cpp/mock_semantic_analyzer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "libqasm/v3x/analysis_result.hpp" 6 | #include "libqasm/v3x/analyzer.hpp" 7 | #include "libqasm/v3x/semantic_analyzer.hpp" 8 | 9 | namespace cqasm::v3x::analyzer { 10 | 11 | struct MockSemanticAnalyzer : public SemanticAnalyzer { 12 | explicit MockSemanticAnalyzer(Analyzer& analyzer) 13 | : SemanticAnalyzer{ analyzer } {} 14 | 15 | [[nodiscard]] AnalysisResult& result() { return result_; } 16 | }; 17 | 18 | } // namespace cqasm::v3x::analyzer 19 | -------------------------------------------------------------------------------- /test/v3x/python/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuTech-Delft/libqasm/bd7931f4e3f6b3d54502b91566736b78d35f88b4/test/v3x/python/__init__.py -------------------------------------------------------------------------------- /test/v3x/python/test_analysis_result.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import cqasm.v3x as cq 4 | 5 | 6 | class TestAnalysisResult(unittest.TestCase): 7 | def test_to_json_with_analyzer_errors(self): 8 | # res/v3x/tests/integration/qubit_array_definition/qubit_array_of_0_q 9 | program_str = "version 3; qubit[0] q" 10 | v3x_analyzer = cq.Analyzer() 11 | actual_errors_json = v3x_analyzer.analyze_string_to_json(program_str) 12 | expected_errors_json = '''{"errors":[{"range":{"start":{"line":1,"character":21},"end":{"line":1,"character":22}},"message":"found qubit array of size <= 0","severity":1}]}''' 13 | self.assertEqual(actual_errors_json, expected_errors_json) 14 | 15 | def test_to_json_with_analyzer_ast(self): 16 | # res/v3x/tests/integration/qubit_array_definition/qubit_array_of_17_q 17 | program_str = "version 3; qubit[17] q" 18 | v3x_analyzer = cq.Analyzer() 19 | actual_ast_json = v3x_analyzer.analyze_string_to_json(program_str) 20 | expected_ast_json = '''{"Program":{"api_version":"3.0","version":{"Version":{"items":"3"}},"block":{"Block":{"statements":[]}},"variables":[{"Variable":{"name":"q","typ":{"QubitArray":{"size":"17"}},"annotations":[]}}]}}''' 21 | self.assertEqual(actual_ast_json, expected_ast_json) 22 | -------------------------------------------------------------------------------- /version.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | 4 | 5 | def get_version(verbose=False): 6 | """Extract version information from source code""" 7 | 8 | root_dir = os.getcwd() # root of the repository 9 | inc_dir = os.path.join(root_dir, "include", "libqasm") # C++ include directory 10 | matcher = re.compile('static const char\* version\{ "(.*)" \}') 11 | version = None 12 | with open(os.path.join(inc_dir, "versioning.hpp"), "r") as f: 13 | for ln in f: 14 | m = matcher.match(ln) 15 | if m: 16 | version = m.group(1) 17 | break 18 | 19 | if verbose: 20 | print("get_version: %s" % version) 21 | 22 | return version 23 | --------------------------------------------------------------------------------