KaiquanMah commited on
Commit
22b578d
·
verified ·
1 Parent(s): 125fe1b

[FIX] store labels found, GOTO label linenumber

Browse files
Week 7 Libraries and More Python/{20. Own programming language, Part 3: Jump command → [FIXED]20. Own programming language, Part 3: Jump command} RENAMED
@@ -227,6 +227,10 @@ LABEL end
227
  PRINT a'''
228
 
229
  print(execute(eg1))
 
 
 
 
230
 
231
 
232
 
@@ -246,6 +250,11 @@ LABEL per2
246
  PRINT a'''
247
 
248
  print(execute(eg2))
 
 
 
 
 
249
 
250
 
251
 
@@ -263,6 +272,8 @@ GOTO point2
263
  LABEL end'''
264
 
265
  print(execute(eg3))
 
 
266
 
267
 
268
 
@@ -271,3 +282,57 @@ print(execute(eg3))
271
 
272
 
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  PRINT a'''
228
 
229
  print(execute(eg1))
230
+ 29
231
+
232
+
233
+
234
 
235
 
236
 
 
250
  PRINT a'''
251
 
252
  print(execute(eg2))
253
+ 88
254
+ 88
255
+
256
+
257
+
258
 
259
 
260
 
 
272
  LABEL end'''
273
 
274
  print(execute(eg3))
275
+ 43
276
+
277
 
278
 
279
 
 
282
 
283
 
284
 
285
+ '''autograder actual, expected output
286
+
287
+ Testing code:
288
+ LET a=96
289
+ GOTO end
290
+ INC a 10
291
+ INC a 20
292
+ LABEL end
293
+ PRINT a
294
+
295
+ Program outputs:
296
+ 96
297
+
298
+
299
+
300
+
301
+ Testing code:
302
+ LET a=58
303
+ GOTO spot1
304
+ INC a 10
305
+ INC a 20
306
+ LABEL spot1
307
+ PRINT a
308
+ GOTO spot2
309
+ DEC a 20
310
+ DEC a 30
311
+ LABEL spot2
312
+ PRINT a
313
+
314
+ Program outputs:
315
+ 58
316
+ 58
317
+
318
+
319
+
320
+
321
+ Testing code:
322
+ GOTO spot1
323
+ LABEL spot3
324
+ PRINT a
325
+ GOTO end
326
+ LABEL spot2
327
+ DEC a 10
328
+ GOTO spot3
329
+ LABEL spot1
330
+ LET a=80
331
+ GOTO spot2
332
+ LABEL end
333
+
334
+ Program outputs:
335
+ 70
336
+
337
+
338
+ '''