Skip to content

Rename qsc_qasm3 to qsc_qasm #2307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
matrix:
os: [ubuntu-latest] # Fuzzing is not supported on Win. The macos is temporarily removed
# because of low availability.
target_name: [qsharp, qasm3]
target_name: [qsharp, qasm]

runs-on: ${{ matrix.os }}
permissions:
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ members = [
"compiler/qsc_partial_eval",
"compiler/qsc_passes",
"compiler/qsc_project",
"compiler/qsc_qasm3",
"compiler/qsc_qasm",
"compiler/qsc_rir",
"fuzz",
"katas",
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ qsc_passes = { path = "../qsc_passes" }
qsc_parse = { path = "../qsc_parse" }
qsc_partial_eval = { path = "../qsc_partial_eval" }
qsc_project = { path = "../qsc_project", features = ["fs"] }
qsc_qasm3 = { path = "../qsc_qasm3", features = ["fs"] }
qsc_qasm = { path = "../qsc_qasm", features = ["fs"] }
qsc_rca = { path = "../qsc_rca" }
qsc_circuit = { path = "../qsc_circuit" }
rustc-hash = { workspace = true }
Expand Down
26 changes: 12 additions & 14 deletions compiler/qsc/src/qasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@

use std::path::Path;

use qsc_qasm3::io::SourceResolver;
pub use qsc_qasm3::CompilerConfig;
pub use qsc_qasm3::OperationSignature;
pub use qsc_qasm3::OutputSemantics;
pub use qsc_qasm3::ProgramType;
pub use qsc_qasm3::QasmCompileUnit;
pub use qsc_qasm3::QubitSemantics;
use qsc_qasm::io::SourceResolver;
pub use qsc_qasm::{
CompilerConfig, OperationSignature, OutputSemantics, ProgramType, QasmCompileUnit,
QubitSemantics,
};
pub mod io {
pub use qsc_qasm3::io::*;
pub use qsc_qasm::io::*;
}
pub mod parser {
pub use qsc_qasm3::parser::*;
pub use qsc_qasm::parser::*;
}
pub mod error {
pub use qsc_qasm3::Error;
pub use qsc_qasm3::ErrorKind;
pub use qsc_qasm::Error;
pub use qsc_qasm::ErrorKind;
}
pub mod completion {
pub use qsc_qasm3::parser::completion::*;
pub use qsc_qasm::parser::completion::*;
}
pub use qsc_qasm3::compile_to_qsharp_ast_with_config;
pub use qsc_qasm3::package_store_with_qasm;
pub use qsc_qasm::compile_to_qsharp_ast_with_config;
pub use qsc_qasm::package_store_with_qasm;

#[must_use]
pub fn parse_raw_qasm_as_fragments<S, P, R>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "qsc_qasm3"
name = "qsc_qasm"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down Expand Up @@ -32,7 +32,7 @@ miette = { workspace = true, features = ["fancy"] }
# Self import adding fs feature so that we can test
# loading qasm from file.
qsc = { path = "../qsc" }
qsc_qasm3 = { path = ".", features = ["fs"] }
qsc_qasm = { path = ".", features = ["fs"] }
qsc_codegen = { path = "../qsc_codegen" }

[features]
Expand Down
4 changes: 2 additions & 2 deletions compiler/qsc_qasm3/README.md → compiler/qsc_qasm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Q# QASM3 Compiler
# Q# QASM Compiler

This crate implements a semantic transformation from OpenQASM 3 to Q#. At a high level it parses the OpenQASM program (and all includes) into an AST. Once this AST is parsed, it is compiled into Q#'s AST.
This crate implements a semantic transformation from OpenQASM to Q#. At a high level it parses the OpenQASM program (and all includes) into an AST. Once this AST is parsed, it is compiled into Q#'s AST.

Once the compiler gets to the AST phase, it no longer cares that it is processing Q#. At this point all input is indistinguishable from having been given Q# as input. This allows us to leverage capability analysis, runtime targeting, residual computation, partial evaluation, and code generation to the input.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use qsc_qasm3::{
use qsc_qasm::{
compile_to_qsharp_ast_with_config, io::InMemorySourceResolver, CompilerConfig, OutputSemantics,
ProgramType, QasmCompileUnit, QubitSemantics,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ impl QasmCompiler {
.filter_map(|annotation| self.compile_annotation(annotation));

// We use the same primitives used for declaring gates, because def declarations
// in QASM3 can take qubits as arguments and call quantum gates.
// in QASM can take qubits as arguments and call quantum gates.
Some(build_function_or_operation(
name,
cargs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ pub struct Error(pub CompilerErrorKind);
#[derive(Clone, Debug, Diagnostic, Eq, Error, PartialEq)]
pub enum CompilerErrorKind {
#[error("annotations only valid on def and gate statements")]
#[diagnostic(code("Qsc.Qasm3.Compiler.InvalidAnnotationTarget"))]
#[diagnostic(code("Qasm.Compiler.InvalidAnnotationTarget"))]
InvalidAnnotationTarget(#[label] Span),
#[error("gate expects {0} qubit arguments, but {1} were provided")]
#[diagnostic(code("Qsc.Qasm3.Compiler.InvalidNumberOfQubitArgs"))]
#[diagnostic(code("Qasm.Compiler.InvalidNumberOfQubitArgs"))]
InvalidNumberOfQubitArgs(usize, usize, #[label] Span),
#[error("{0} are not supported")]
#[diagnostic(code("Qsc.Qasm3.Compiler.NotSupported"))]
#[diagnostic(code("Qasm.Compiler.NotSupported"))]
NotSupported(String, #[label] Span),
#[error("Qiskit circuits must have output registers")]
#[diagnostic(code("Qsc.Qasm3.Compiler.QiskitEntryPointMissingOutput"))]
#[diagnostic(code("Qasm.Compiler.QiskitEntryPointMissingOutput"))]
QiskitEntryPointMissingOutput(#[label] Span),
#[error("unexpected annotation: {0}")]
#[diagnostic(code("Qsc.Qasm3.Compiler.UnknownAnnotation"))]
#[diagnostic(code("Qasm.Compiler.UnknownAnnotation"))]
UnknownAnnotation(String, #[label] Span),
#[error("this statement is not yet handled during OpenQASM 3 import: {0}")]
#[diagnostic(code("Qsc.Qasm3.Compiler.Unimplemented"))]
#[diagnostic(code("Qasm.Compiler.Unimplemented"))]
Unimplemented(String, #[label] Span),
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ pub(crate) struct Token {
#[derive(Clone, Copy, Debug, Diagnostic, Eq, Error, PartialEq)]
pub enum Error {
#[error("expected {0} to complete {1}, found {2}")]
#[diagnostic(code("Qasm3.Lex.Incomplete"))]
#[diagnostic(code("Qasm.Lex.Incomplete"))]
Incomplete(raw::TokenKind, TokenKind, raw::TokenKind, #[label] Span),

#[error("expected {0} to complete {1}, found EOF")]
#[diagnostic(code("Qasm3.Lex.IncompleteEof"))]
#[diagnostic(code("Qasm.Lex.IncompleteEof"))]
IncompleteEof(raw::TokenKind, TokenKind, #[label] Span),

#[error("unterminated string literal")]
#[diagnostic(code("Qasm3.Lex.UnterminatedString"))]
#[diagnostic(code("Qasm.Lex.UnterminatedString"))]
UnterminatedString(#[label] Span),

#[error("string literal with an invalid escape sequence")]
#[diagnostic(code("Qasm3.Lex.InvalidEscapeSequence"))]
#[diagnostic(code("Qasm.Lex.InvalidEscapeSequence"))]
InvalidEscapeSequence(#[label] Span),

#[error("unrecognized character `{0}`")]
#[diagnostic(code("Qasm3.Lex.UnknownChar"))]
#[diagnostic(code("Qasm.Lex.UnknownChar"))]
Unknown(char, #[label] Span),
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl CompilerConfig {
fn namespace(&self) -> Arc<str> {
self.namespace
.clone()
.unwrap_or_else(|| Arc::from("qasm3_import"))
.unwrap_or_else(|| Arc::from("qasm_import"))
}
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -87,55 +87,55 @@ pub enum ErrorKind {
#[diagnostic(transparent)]
Lex(lex::Error),
#[error("invalid {0} literal")]
#[diagnostic(code("Qasm3.Parse.Literal"))]
#[diagnostic(code("Qasm.Parse.Literal"))]
Lit(&'static str, #[label] Span),
#[error("unknown escape sequence: `{0}`")]
#[diagnostic(code("Qasm3.Parse.Escape"))]
#[diagnostic(code("Qasm.Parse.Escape"))]
Escape(char, #[label] Span),
#[error("expected {0}, found {1}")]
#[diagnostic(code("Qasm3.Parse.Token"))]
#[diagnostic(code("Qasm.Parse.Token"))]
Token(TokenKind, TokenKind, #[label] Span),
#[error("Empty statements are not supported")]
#[diagnostic(code("Qasm3.Parse.EmptyStatement"))]
#[diagnostic(code("Qasm.Parse.EmptyStatement"))]
EmptyStatement(#[label] Span),
#[error("Annotation missing target statement.")]
#[diagnostic(code("Qasm3.Parse.FloatingAnnotation"))]
#[diagnostic(code("Qasm.Parse.FloatingAnnotation"))]
FloatingAnnotation(#[label] Span),
#[error("expected {0}, found {1}")]
#[diagnostic(code("Qasm3.Parse.Rule"))]
#[diagnostic(code("Qasm.Parse.Rule"))]
Rule(&'static str, TokenKind, #[label] Span),
#[error("expected {0}, found {1}")]
#[diagnostic(code("Qasm3.Parse.Convert"))]
#[diagnostic(code("Qasm.Parse.Convert"))]
Convert(&'static str, &'static str, #[label] Span),
#[error("expected statement to end with a semicolon")]
#[diagnostic(code("Qasm3.Parse.MissingSemi"))]
#[diagnostic(code("Qasm.Parse.MissingSemi"))]
MissingSemi(#[label] Span),
#[error("expected inputs to be parenthesized")]
#[diagnostic(code("Qasm3.Parse.MissingParens"))]
#[diagnostic(code("Qasm.Parse.MissingParens"))]
MissingParens(#[label] Span),
#[error("missing entry in sequence")]
#[diagnostic(code("Qasm3.Parse.MissingSeqEntry"))]
#[diagnostic(code("Qasm.Parse.MissingSeqEntry"))]
MissingSeqEntry(#[label] Span),
#[error("missing switch statement cases")]
#[diagnostic(code("Qasm3.Parse.MissingSwitchCases"))]
#[diagnostic(code("Qasm.Parse.MissingSwitchCases"))]
MissingSwitchCases(#[label] Span),
#[error("missing switch statement case labels")]
#[diagnostic(code("Qasm3.Parse.MissingSwitchCaseLabels"))]
#[diagnostic(code("Qasm.Parse.MissingSwitchCaseLabels"))]
MissingSwitchCaseLabels(#[label] Span),
#[error("missing gate call operands")]
#[diagnostic(code("Qasm3.Parse.MissingGateCallOperands"))]
#[diagnostic(code("Qasm.Parse.MissingGateCallOperands"))]
MissingGateCallOperands(#[label] Span),
#[error("expected an item or closing brace, found {0}")]
#[diagnostic(code("Qasm3.Parse.ExpectedItem"))]
#[diagnostic(code("Qasm.Parse.ExpectedItem"))]
ExpectedItem(TokenKind, #[label] Span),
#[error("gphase gate requires exactly one angle")]
#[diagnostic(code("Qasm3.Parse.GPhaseInvalidArguments"))]
#[diagnostic(code("Qasm.Parse.GPhaseInvalidArguments"))]
GPhaseInvalidArguments(#[label] Span),
#[error("invalid gate call designator")]
#[diagnostic(code("Qasm3.Parse.InvalidGateCallDesignator"))]
#[diagnostic(code("Qasm.Parse.InvalidGateCallDesignator"))]
InvalidGateCallDesignator(#[label] Span),
#[error("multiple index operators are only allowed in assignments")]
#[diagnostic(code("Qasm3.Parse.MultipleIndexOperators"))]
#[diagnostic(code("Qasm.Parse.MultipleIndexOperators"))]
MultipleIndexOperators(#[label] Span),
#[error(transparent)]
#[diagnostic(transparent)]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ use thiserror::Error;
#[derive(Clone, Debug, Diagnostic, Eq, Error, PartialEq)]
pub enum ConstEvalError {
#[error("expression must be const")]
#[diagnostic(code("Qsc.Qasm3.Compile.ExprMustBeConst"))]
#[diagnostic(code("Qasm.Compile.ExprMustBeConst"))]
ExprMustBeConst(#[label] Span),
#[error("uint expression must evaluate to a non-negative value, but it evaluated to {0}")]
#[diagnostic(code("Qsc.Qasm3.Compile.NegativeUIntValue"))]
#[diagnostic(code("Qasm.Compile.NegativeUIntValue"))]
NegativeUIntValue(i64, #[label] Span),
#[error("{0} doesn't fit in {1}")]
#[diagnostic(code("Qsc.Qasm3.Compile.ValueOverflow"))]
#[diagnostic(code("Qasm.Compile.ValueOverflow"))]
ValueOverflow(String, String, #[label] Span),
}

Expand Down
Loading