You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, firstly, thanks for the package! It has been a huge help to me.
I have found that when the names of qregs or cregs are multiple characters, only the last character of the name appears in the 'qreg_name' entry of elements in 'c_sect' with 'type' ASTType.QREG or ASTType.CREG. For example, a register called 'reg' would give return the value 'g' for the 'qreg_name' key.
This behaviour seems to stem from the line 233 to 235 of nuqasm2/qasmast.py (accessed 19/10/2023. The relevant lines are:
x = QTRegEx.REG_DECL.match(self.source)
self.qreg_name = x.group(1)
self.qreg_num = x.group(2)
One can replicate the issue without needing to run a specific file by modifying the above lines to read:
from nuqasm2.qasmast import QTRegEx
a_string = 'qreg reg[5]'
x = QTRegEx.REG_DECL.match(a_string)
print(x.group()) #gives 'qreg reg[5]'. This demonstrates that the matching is working as expected
qreg_name = x.group(1)
print(qreg_name) #gives 'g', rather than 'reg'
As I am new to regex, I personally fixed this using the 3rd-party pyparsing package by implementing the class:
Hi, firstly, thanks for the package! It has been a huge help to me.
I have found that when the names of qregs or cregs are multiple characters, only the last character of the name appears in the 'qreg_name' entry of elements in 'c_sect' with 'type' ASTType.QREG or ASTType.CREG. For example, a register called 'reg' would give return the value 'g' for the 'qreg_name' key.
This behaviour seems to stem from the line 233 to 235 of nuqasm2/qasmast.py (accessed 19/10/2023. The relevant lines are:
One can replicate the issue without needing to run a specific file by modifying the above lines to read:
As I am new to regex, I personally fixed this using the 3rd-party pyparsing package by implementing the class:
and then changing 233 to 235 of nuqasm2/qasmast.py to
However, obviously this does have the drawback of adding another dependency to the nuqasm2 package.
NOTE: The issue with cregs is identical.
The text was updated successfully, but these errors were encountered: