Skip to content

Commit 8d28fad

Browse files
committed
Update settings function
1 parent 6014d46 commit 8d28fad

File tree

16 files changed

+77
-48
lines changed

16 files changed

+77
-48
lines changed

example.pfcf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,23 @@ by Eanorambuena,|
2121

2222
Add qiskit code like this:,|
2323
\<qiskit\>,
24-
$host qasm_simulator,
2524
q0 q1,
2625
X,
2726
H,
2827
.---X,
2928
c1,
29+
$host qasm_simulator,
30+
$hist true,
31+
$draw true,
3032
\</qiskit\>,
3133

3234
<qiskit>
33-
$host qasm_simulator
3435
q0 q1
3536
X
3637
H
3738
.---X
3839
c1
39-
</qiskit>
40+
$host qasm_simulator
41+
$hist true
42+
$draw true
43+
</qiskit>,

example.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ by Eanorambuena
1818
Add qiskit code like this:
1919

2020
<qiskit>
21-
$host qasm_simulator
2221
q0 q1
2322
X
2423
H
2524
.---X
2625
c1
26+
$host qasm_simulator
27+
$hist true
28+
$draw true
2729
</qiskit>

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pfcf.read import read,executepfcf
2-
2+
from pfcf.utils import execute
33
name="example"
4+
#execute("qiskit_compile")
45
executepfcf(name)

pfcf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from pfcf.files import *
22
from pfcf.read import *
3-
from pfcf.parser import *
3+
from pfcf.utils import *
-1 Bytes
Binary file not shown.
-65 Bytes
Binary file not shown.
-23 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
1.47 KB
Binary file not shown.

pfcf/code.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22
import pfcf.codel.qiskit as q
33

44
def codef(codel: str,text: str): #code function
5-
form=".compile.py"
5+
form="_compile.py"
66
f=open(codel+form,"w")
77
t=""
88
if codel=="qiskit":
99
t=qiskit(text)
1010
f.write(t)
1111
f.close()
12-
sleep(1000)
13-
delete(codel,form)
1412

1513
def qiskit(text: str):
16-
t=[]
17-
t.append("from qiskit import QuantumCircuit, execute, Aer\n")
18-
t.append("from qiskit.visualization import plot_histogram\n")
1914
T=""
15+
T+="from qiskit import QuantumCircuit, execute, Aer\n"
16+
T+="from qiskit.visualization import plot_histogram,display\n"
2017
s=0
2118
command=""
2219
param=""
@@ -25,7 +22,9 @@ def qiskit(text: str):
2522
gatecount=0
2623
qdef=0
2724
for i in text:
28-
if s==1: #settings mode on
25+
if i==",":
26+
pass
27+
elif s==1: #settings mode on
2928
if i!=" ":
3029
command+=i
3130
else:
@@ -34,7 +33,9 @@ def qiskit(text: str):
3433
if i!=" " and i!="\n":
3534
param+=i
3635
else:
37-
t.append(q.settings(command,param))
36+
T+=q.settings(command,param)
37+
command=""
38+
param=""
3839
s=0
3940
elif i=="$":
4041
s=1
@@ -43,23 +44,20 @@ def qiskit(text: str):
4344
Q+=1
4445
elif i=="\n":
4546
qdef=2
46-
t.append("circuit== QuantumCircuit("+str(Q)+","+str(Q)+")\n")
47+
T+="circuit=QuantumCircuit("+str(Q)+","+str(Q)+")\n"
4748
elif qdef==2:
4849
if i!="\n" and i!=" ":
4950
gate+=i
5051
elif i==" ":
5152
gatecount+=0.5
52-
t.append(q.quantum(gate,gatecount))
53+
T+=q.quantum(gate,gatecount)
5354
gate=""
5455
else:
55-
t.append(q.quantum(gate,gatecount))
56+
T+=q.quantum(gate,gatecount)
5657
gate=""
5758
gatecount=0
5859
elif i=="q":
5960
qdef=1
6061
Q+=1
61-
62-
for i in t:
63-
T+=i
6462
return T
6563

0 commit comments

Comments
 (0)