-
Notifications
You must be signed in to change notification settings - Fork 118
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
Reimplement Parser #2149
base: main
Are you sure you want to change the base?
Reimplement Parser #2149
Conversation
80a46cc
to
348680f
Compare
dced819
to
cec25d5
Compare
Index, | ||
} | ||
|
||
// TODO: This seems to be an unnecessary wrapper. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
Keyword(Keyword), | ||
} | ||
|
||
// TODO: This seems to be an unnecessary wrapper. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
eb82b24
to
b803573
Compare
compiler/qsc_qasm3/src/compiler.rs
Outdated
|
||
let ast_ty = map_qsharp_type_to_ast_ty(&output_ty); | ||
signature.output = format!("{output_ty}"); | ||
// TODO: This can create a collision on multiple compiles when interactive |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
|
||
// input decls should have been pushed to symbol table, | ||
// but should not be the stmts list. | ||
// TODO: This may be an issue for tooling as there isn't a way to have a forward |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
) | ||
} | ||
|
||
// TODO: which these are parsed as different types, they are effectively the same |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
Type::BitArray(..) => { | ||
rewrap_lit!(lit, Bitstring(val, _), Int(i64::try_from(val).ok()?)) | ||
} | ||
// TODO: UInt Overflowing behavior. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
// already is a i64. Therefore, there is nothing to do? | ||
Type::Int(..) | Type::UInt(..) => Some(lit), | ||
Type::Float(..) => rewrap_lit!(lit, Float(val), { | ||
// TODO: we need to issue the same lint in Q#. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
Type::BitArray(..) => { | ||
rewrap_lit!(lit, Bitstring(val, _), Int(i64::try_from(val).ok()?)) | ||
} | ||
// TODO: Int Overflowing behavior. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
// same result anyways. Need to think through this. | ||
Type::Int(..) | Type::UInt(..) => Some(lit), | ||
Type::Float(..) => rewrap_lit!(lit, Float(val), { | ||
// TODO: we need to issue the same lint in Q#. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
This PR adds our own implementation of an OpenQASM3 parser to the `compiler/qsc_qasm3` directory.
Co-authored-by: Oscar Puente <[email protected]>
This PR completes the lowering and compilation for: - [x] gate definitions - [x] gphase - [x] for stmt - [x] if stmt - [x] switch stmt - [x] return stmt - [x] classical function calls - [x] classical function decls It also does some partial work to make the compiler infallible, by returning `ExprKind::Err` instead of None when compiling expressions.
Add implicit casts to function and gate arguments.
This PR adds angle support to the new compiler. --------- Co-authored-by: Ian Davis <[email protected]>
} | ||
Type::Float(..) => { | ||
rewrap_lit!((lhs, rhs), (Float(lhs), Float(rhs)), { | ||
// TODO: we need to issue the same lint in Q#. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
} | ||
Type::Float(..) => { | ||
rewrap_lit!((lhs, rhs), (Float(lhs), Float(rhs)), { | ||
// TODO: we need to issue the same lint in Q#. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
match ty { | ||
Type::Bool(..) => rewrap_lit!(lit, Bool(val), Float(if val { 1.0 } else { 0.0 })), | ||
Type::Int(..) | Type::UInt(..) => rewrap_lit!(lit, Int(val), { | ||
// TODO: we need to issue the same lint in Q#. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
Compile functions and operations const evaluating any references to symbol in an external scope.
This PR: - [x] Unignores 32/52 unit tests that are now supported. - [x] Passes a couple of spans to the ast_builder that were previously set to default. - [x] Makes constant measurements like in `const bit res = measure q;` a parser error. - [x] Only generates gate functors when `@SimulatableIntrinsic` is not present. - [x] break stmt - [x] continue stmt - [x] lower duration literals - [x] fixes bug when handling `void` return type - [x] return stmt casts to the return type of the function
Lexing
Parsing
Lowering
Compiling
EntryPoint()
attr on operation when compiling in file modeFit and Finish
&mut Lowerer
as an argument so that it can push semantic errors. Better error messages for const evaluator #2277Postponed
bit x = 0; bit y = ~x;
is valid QASM3, but it gets compiled tolet x = Zero; let y = ~~~x;
which is invalid Q# code, since theResult
type in Q# doesn't support unary bitwise negation. This is the same for all other operations that bit should support, Q# Result only supports equality.uint
types must be positive, since they are compiled to Q#Int
which are signed. We might need aUInt
type similar to theAngle
type introduced in Add angle support to the new compiler #2267 to be able to enforce this constraint.Ident
asRc<Symbol>
and not asSymbolId
to avoid an unnecessarySymbolTable
lookup? In that way we don't even need to pass the symbol table to the compiler.SymbolId
s when creating the function type, so that we can give the user a better error message when they pass an argument that fails implicit casting to a function. There is a catch: we need to insert the function symbol into the symbol table before pushing the scope where the formal parameters live, but we need theSymbolId
s of the formal parameters to construct the function symbol.