Can't parse quil code with a call to a DEFCIRCUIT with no arguments
See original GitHub issueThis does not parse:
DEFCIRCUIT FOO:
NOP
FOO
But this is OK:
DEFCIRCUIT FOO a:
NOP
FOO 1
python -c 'from pyquil._parser.PyQuilListener import run_parser; run_parser("DEFCIRCUIT FOO:\n NOP\nFOO")'
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Editor error thrown: Quill is not defined · Issue #518 - GitHub
An error is thrown when opening the Rich Text Editor for the first time or if reloading the page using Empty Cache and...
Read more >Javascript JSON.parse() error while trying to parse stringified ...
2 Answers 2 · Still cannot parse the following string resulted from changing data.toString() to JSON. · That's not valid JSON. Put it...
Read more >API - Quill Rich Text Editor
Quill is a free, open source WYSIWYG editor built for the modern web. Completely customize it for any need with its modular architecture...
Read more >ED311449.pdf - ERIC - Department of Education
This book contains 25 essays about English words, and how they are defined, valued, and discussed. The book is divided into four sections....
Read more >The Death Penalty in 2021: Year End Report
Once again, only defendants of color were executed for cross-racial murders and no white defendant was sentenced to death in a trial that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d like to add my opinion that I don’t like that the body of a DEFCIRCUIT can reference static qubit literals at all. I’d strongly prefer
FOO 1
to account for all of the qubits touched byFOO
: the qubit1
, and only qubit1
.A basic issue is that pyquil has no distinction between gate applications and circuit applications (everything gets parsed into
Gate
objects), and resolution is done by name via global lookup tables likeQUANTUM_GATES
.For example, one easy way to allow for nullary circuit applications in the parser is to change
to
in
Quil.g4
, and correspondingly removefrom
Gate.__init__
.But this is a bad idea, because we should be enforcing the non-nullary condition for gate applications.
The way that the quilc parser addresses this is to actually do two passes. The initial parsing produces an “unresolved application” object. A second pass resolves applications to gate applications or circuit applications, depending on the presence of suitable
DEFCIRCUIT
etc. The resolved objects are tagged with some important information: a pointer to their corresponding gate or circuit definitions. This is an additional level of detail that pyquil does not maintain (in pyquil, aGate
instruction has only a name, with no explicit reference to its corresponding definition).