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

Fix parsing DEFCIRCUIT without qubits #689

Merged

Conversation

notmgsk
Copy link
Contributor

@notmgsk notmgsk commented Nov 12, 2018

Parsing a DEFCIRCUIT which has no qubit parameters outputs an
extraneous spacing before the colon:

>>> from pyquil.parser import parse
>>> from pyquil._parser.PyQuilListener import run_parser
>>> from pyquil.quilbase import RawInstr
>>> print(run_parser("DEFCIRCUIT TEST:\n    MEASURE 0 ro\n"))'

[<RawInstr DEFCIRCUIT TEST :
    MEASURE 0 ro[0]>]

Parsing a DEFCIRCUIT which has no qubit parameters outputs an
extraneous spacing before the colon:

```
>>> from pyquil.parser import parse
>>> from pyquil._parser.PyQuilListener import run_parser
>>> from pyquil.quilbase import RawInstr
>>> print(run_parser("DEFCIRCUIT TEST:\n    MEASURE 0 ro\n"))'

[<RawInstr DEFCIRCUIT TEST :
    MEASURE 0 ro[0]>]
```
@@ -128,11 +128,12 @@ def exitDefCircuit(self, ctx: QuilParser.DefCircuitContext):
circuit_name = ctx.name().getText()
variables = [variable.getText() for variable in ctx.variable()]
qubitVariables = [qubitVariable.getText() for qubitVariable in ctx.qubitVariable()]
space = ' ' if qubitVariables else ''
Copy link
Contributor Author

@notmgsk notmgsk Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the cleanest way to achieve the correct result. The best fix would be to have Circuit in pyquil.

Copy link
Contributor

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@mpharrigan mpharrigan merged commit de221d5 into rigetti:master Nov 13, 2018
@karalekas karalekas added this to the v2.1.0 milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants