-
Notifications
You must be signed in to change notification settings - Fork 112
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
rc::Rc, | ||
}; | ||
|
||
// TODO: Profile this with iai-callgrind in a large OpenQASM3 |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
|
||
let expr = if matches!(ty, Type::Complex(..)) { | ||
if is_complex_binop_supported(op) { | ||
// TODO: How do we handle complex binary expressions? |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
eb82b24
to
b803573
Compare
|
||
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::Float(..) | Type::Angle(..) => { | ||
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(..) | Type::Angle(..) => { | ||
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::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
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
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 doesn't change any behavior. It just touches the Display functions in the QASM3 parser to make unit tests easier to read.
Previously assignments and binary assignments were valid in any part of the expression tree. This PR makes Assign and AssignOp valid only in expression statements.
This PR turns assignment into a StmtKind (it was a ExprKind before).
This PR: 1. Fixes a bug with block statements 2. Adds grammar docstrings to the QASM3 parser. 3. Adds the invalid tests in the reference parser to make sure they are invalid for our parser as well.
…es. (#2226) If/else blocks, while, and for loops in QASM introduce new scopes only when their body enclosed by curly braces. To make lowering easier, this PR changes their bodies from `List<Stmt>` to `Stmt`. In the body enclosed in curly braces case, the Stmt will be of kind Block.
- Adding span offsetter for parsed files - Clean up error spans - Move box validation - Add a mutable visitor for AST nodes.
This PR: 1. Aliases super::ast to semantic. 2. Fixes The bodies of if, for, and while to be `Stmt` instead of `List<Stmt>`. 3. Lowers the if, for, while, and switch stmts. 4. Refactors the pattern used to handle lowering of optional items by introducing the `short_circuit_opt_item!` macro.
…ler (#2246) This PR adds gate calls and the AST items it depends on to the new QASM3 compiler: - [x] Constant evaluation (needed for array sizes and type widths). - [x] Unit tests. - [x] QuantumDeclStmt - [x] IndexedAssignStmt. - [x] Bitarrays. - [x] MeasureExpr / MeasureStmt. - [x] Compilation to Result type (introduces `LiteralKind::Bit(bool)`) variant. - [x] GatecallStmt - [x] barrier - [x] reset
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.
Lexing
Parsing
Lowering
Ident
asSymbol
and not asSymbolId
.SymbolId
s when creating the function type. In that way, 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.Compiling
EntryPoint()
attr on operation when compiling in file modeFit and Finish