3
3
from importlib import import_module
4
4
from time import sleep
5
5
6
+ last_line = ""
6
7
key_layout = "us"
7
8
default_delay = 10
8
9
string_delay = 1
@@ -38,16 +39,20 @@ def string(string):
38
39
def pharse (line , known , deltrue ):
39
40
global default_delay
40
41
global string_delay
41
- if line != " " :
42
- command = line . split ()
43
- else :
42
+ if line == " " :
43
+ return
44
+ elif line == " " :
44
45
command = [" " ]
46
+ else :
47
+ command = line .split ()
45
48
if command [0 ] == "DELAY" :
46
49
sleep (int (command [1 ]) / 100 )
47
50
return
48
51
elif command [0 ] == "REM" :
49
52
return
50
53
elif command [0 ] == "REPEAT" :
54
+ for i in range (int (command [1 ])):
55
+ pharse (last_line .strip (), [[], []], False )
51
56
return # todo
52
57
elif command [0 ] == "DEFAULTCHARDELAY" :
53
58
string_delay = int (command [1 ])
@@ -63,14 +68,14 @@ def pharse(line, known, deltrue):
63
68
return
64
69
elif command [0 ] in keymap .commap :
65
70
known [0 ].append (keymap .commap [command [0 ]])
66
- if len (command ) > 0 :
71
+ if len (command ) > 1 :
67
72
pharse (" " .join (command [1 :]), known , True )
68
73
else :
69
74
out (known )
70
75
return
71
76
elif command [0 ] in keymap .c1map :
72
77
known [1 ].append (keymap .c1map [command [0 ]])
73
- if len (command ) > 0 :
78
+ if len (command ) > 1 :
74
79
pharse (" " .join (command [1 :]), known , True )
75
80
else :
76
81
out (known )
@@ -102,20 +107,23 @@ def out(ccl):
102
107
103
108
104
109
def main ():
110
+ global last_line
105
111
if piargs .input is not None :
106
112
file1 = open (piargs .input , "r" )
107
113
while True :
108
114
line = file1 .readline ()
109
115
if not line :
110
116
break
111
117
pharse (line .strip (), [[], []], False )
118
+ last_line = line
112
119
file1 .close ()
113
120
else :
114
121
while True :
115
122
line = input ()
116
123
if not line :
117
124
break
118
125
pharse (line .strip (), [[], []], False )
126
+ last_line = line
119
127
120
128
121
129
main ()
0 commit comments