Skip to content
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

gphase expression cannot have gate modifiers applied #88

Closed
jakelishman opened this issue Jan 31, 2024 · 3 comments · Fixed by #99
Closed

gphase expression cannot have gate modifiers applied #88

jakelishman opened this issue Jan 31, 2024 · 3 comments · Fixed by #99
Labels
bug Something isn't working priority medium

Comments

@jakelishman
Copy link
Member

In trying to parse the stdgates.inc include at the moment, the parser emits syntactic errors on the line

gate p(lambda) a { ctrl @ gphase(lambda) a; }

because it doesn't like the gphase after the modifier:

Error: expected IDENT
   ╭─[/Users/jake/code/qiskit/terra/qiskit/qasm/libs/stdgates.inc:4:27]
 4 │gate p(lambda) a { ctrl @ gphase(lambda) a; }
   │                          ╰ Near this point

Error: expected value parameter
   ╭─[/Users/jake/code/qiskit/terra/qiskit/qasm/libs/stdgates.inc:4:27]
 4 │gate p(lambda) a { ctrl @ gphase(lambda) a; }
   │                          ╰ Near this point

Error: expected SEMICOLON
   ╭─[/Users/jake/code/qiskit/terra/qiskit/qasm/libs/stdgates.inc:4:27]
 4 │gate p(lambda) a { ctrl @ gphase(lambda) a; }
   │                          ╰ Near this point

Error: expected SEMICOLON
   ╭─[/Users/jake/code/qiskit/terra/qiskit/qasm/libs/stdgates.inc:4:41]
 4 │gate p(lambda) a { ctrl @ gphase(lambda) a; }
   │                                        ╰ Near this point

As far as Qiskit is concerned this isn't super important, because we're just going to ignore whatever's going on in stdlib gate statements anyway, but it does mean we can't use the proper version of the file on our import path yet.

@jlapeyre
Copy link
Collaborator

Whoops. Just saw this now. Thanks.

@jakelishman
Copy link
Member Author

ha no worries - I only noticed and posted it a few minutes ago

@jlapeyre
Copy link
Collaborator

This is a pretty quick fix. But I'll look at it after I've finished chores for 1.0.

jlapeyre added a commit that referenced this issue Feb 4, 2024
This commit adds support for gphase calls with gate modifiers.
gpahse calls *without* modifiers are, as before, represented by
`asg::Stmt::GPhaseCall`.
gphase calls *with* modifiers are represented by
`asg::Stmt::ModifiedGPhaseCall`. The latter has the same accessor
`arg()` as `GPhaseCall`. But it adds `modifiers()`.

Closes #88
jlapeyre added a commit that referenced this issue Feb 4, 2024
This commit adds support for gphase calls with gate modifiers.
gpahse calls *without* modifiers are, as before, represented by
`asg::Stmt::GPhaseCall`.
gphase calls *with* modifiers are represented by
`asg::Stmt::ModifiedGPhaseCall`. The latter has the same accessor
`arg()` as `GPhaseCall`. But it adds `modifiers()`.

Closes #88
jlapeyre added a commit that referenced this issue Feb 4, 2024
* Add GPhaseCallExpr

* Replace GPhaseCallStmt with GPhaseCallExpr and ExprStmt

* Add ModifiedGPhaseCall to ASG

* Parse modified gphase to `asg::ModfiedGPhaseCall`

This commit adds support for gphase calls with gate modifiers.
gpahse calls *without* modifiers are, as before, represented by
`asg::Stmt::GPhaseCall`.
gphase calls *with* modifiers are represented by
`asg::Stmt::ModifiedGPhaseCall`. The latter has the same accessor
`arg()` as `GPhaseCall`. But it adds `modifiers()`.

Closes #88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants