Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyquil/_parser/grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def_circuit : "DEFCIRCUIT" name [ variables ] [ qubit_designators ] ":" indented
// | "DEFCIRCUIT" name [ variables ] qubit_designators ":" indented_instrs -> def_circuit_qubits

def_frame : "DEFFRAME" frame ( ":" frame_spec+ )?
frame_spec : _NEWLINE_TAB frame_attr ":" (expression | "\"" name "\"" )
frame_spec : _NEWLINE_TAB frame_attr ":" (expression | string )
!frame_attr : "SAMPLE-RATE"
| "INITIAL-FREQUENCY"
| "DIRECTION"
Expand Down
3 changes: 3 additions & 0 deletions pyquil/_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def def_frame(self, frame, *specs):
for (spec_name, spec_value) in specs:
name = names.get(spec_name, None)
if name:
if isinstance(spec_value, str) and spec_value[0] == '"' and spec_value[-1] == '"':
# Strip quotes if necessary
spec_value = spec_value[1:-1]
options[name] = spec_value
else:
raise ValueError(
Expand Down
11 changes: 11 additions & 0 deletions test/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,14 @@ def test_parse_defgate_as_pauli():
)
def test_parse_comments(program):
Program(program)


def test_parse_strings_with_spaces():
Program(str(Program("""
DEFFRAME 0 "readout_tx":
DIRECTION: "tx"
INITIAL-FREQUENCY: 7220000000.0
CENTER-FREQUENCY: 7125000000
HARDWARE-OBJECT: "A_string_with_one space"
SAMPLE-RATE: 1000000000.0
""")))