git @ Cat's Eye Technologies SixtyPical / master tests / SixtyPical Syntax.md
master

Tree @master (Download .tar.gz)

SixtyPical Syntax.md @master

feb5729
 
49d90df
 
 
 
2dc4dd9
 
 
49d90df
 
feb5729
49d90df
 
 
7c9f76c
49d90df
 
 
 
 
9235c6e
 
 
 
7c9f76c
9235c6e
 
e565234
 
 
 
 
 
9235c6e
 
 
a933c81
 
7c9f76c
a933c81
 
 
 
 
 
49d90df
7c9f76c
49d90df
 
 
 
 
a933c81
522c771
 
 
 
 
 
 
 
49d90df
 
7c9f76c
49d90df
 
 
 
7c9f76c
49d90df
 
 
 
f7eb0d4
1098347
 
 
 
 
 
 
 
 
 
 
 
c7861d3
 
7c9f76c
c7861d3
 
 
 
 
1f992f8
 
7c9f76c
1f992f8
 
 
 
 
f7eb0d4
 
7c9f76c
f7eb0d4
 
 
 
 
 
 
 
 
 
 
7c9f76c
f7eb0d4
 
 
 
 
 
 
 
 
 
7c9f76c
f7eb0d4
 
 
 
 
49e42af
 
 
 
 
 
7c9f76c
49e42af
 
 
 
 
 
 
 
7c9f76c
49e42af
 
 
f7eb0d4
 
522c771
d815e05
 
 
 
7c9f76c
d815e05
b79059f
d815e05
 
 
b79059f
d815e05
 
 
4d1f9d0
 
 
 
b19267d
 
 
7c9f76c
4d1f9d0
 
 
 
 
 
 
 
b19267d
3f666f4
b19267d
 
4d1f9d0
d815e05
 
42438dd
 
 
 
0be7216
b19267d
42438dd
 
7c9f76c
42438dd
 
 
0c22944
0be7216
0c22944
 
 
b19267d
 
0be7216
7c9f76c
0c22944
 
 
 
 
 
 
 
 
 
 
 
 
b19267d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0be7216
 
 
d24e9fa
b19267d
 
 
 
 
 
93e2dad
 
 
7c9f76c
93e2dad
 
 
 
 
 
 
b19267d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93e2dad
 
d24e9fa
93e2dad
7c9f76c
93e2dad
 
 
 
 
 
 
 
 
d24e9fa
93e2dad
7c9f76c
93e2dad
 
 
 
 
 
 
d24e9fa
93e2dad
74f8675
 
 
70ecd52
74f8675
 
 
7c9f76c
74f8675
 
 
 
 
 
 
 
7c9f76c
74f8675
 
 
3f0e36a
 
 
 
 
 
 
 
 
 
 
7c9f76c
3f0e36a
 
 
 
b19267d
 
 
 
 
 
 
 
 
 
 
 
 
3f0e36a
 
 
 
 
7c9f76c
3f0e36a
 
 
7b1ee60
522c771
 
 
7c9f76c
522c771
 
e565234
 
522c771
 
41432b5
6cf8b5f
 
7b1ee60
6cf8b5f
7c9f76c
6cf8b5f
 
 
 
 
9d6ca0b
 
 
 
7c9f76c
9d6ca0b
 
 
 
 
fc8c85e
 
70ecd52
fc8c85e
 
 
 
7c9f76c
fc8c85e
 
 
2f513f7
f87bcf5
70ecd52
f87bcf5
7c9f76c
f87bcf5
 
 
 
 
7c9f76c
f87bcf5
7c9f76c
f87bcf5
 
 
2f513f7
 
 
 
7c9f76c
2f513f7
 
 
41432b5
 
7c9f76c
41432b5
 
 
 
 
 
 
 
 
 
7c9f76c
41432b5
 
 
 
 
 
 
 
 
7c9f76c
41432b5
 
 
 
 
7c9f76c
41432b5
 
 
a12a44e
 
7c9f76c
a12a44e
 
 
 
 
 
 
19dd089
 
7c9f76c
19dd089
 
 
 
 
7c9f76c
19dd089
 
 
 
41432b5
 
7c9f76c
41432b5
 
 
7c9f76c
41432b5
 
 
 
4287bf8
689ed37
4287bf8
70ecd52
4287bf8
7c9f76c
4287bf8
 
 
 
 
 
c98e446
689ed37
70ecd52
689ed37
7c9f76c
689ed37
 
 
 
 
 
 
2dc4dd9
c98e446
0be7216
f0b8942
 
 
0be7216
c98e446
7c9f76c
c98e446
 
7c9f76c
645079f
 
 
2dc4dd9
c98e446
 
f0b8942
 
 
bbd3a84
f0b8942
 
 
bbd3a84
f0b8942
7c9f76c
f0b8942
 
be76b9a
ec2e051
 
0be7216
ec2e051
 
 
0be7216
ec2e051
7c9f76c
ec2e051
 
7c9f76c
ec2e051
 
 
 
 
 
 
2a71c7e
 
0be7216
2a71c7e
 
 
0be7216
2a71c7e
7c9f76c
2a71c7e
 
7c9f76c
2a71c7e
 
 
 
 
 
 
f6fa1ec
 
 
b7b2883
0be7216
b29716f
 
 
0be7216
7c9f76c
0194d37
 
 
 
 
7c9f76c
0194d37
 
b7b2883
 
be76b9a
 
7c9f76c
be76b9a
 
7c9f76c
be76b9a
 
 
 
3814d26
 
 
7c9f76c
19dd089
 
7c9f76c
19dd089
 
 
 
3814d26
 
0be7216
be76b9a
7c9f76c
be76b9a
 
 
 
3814d26
 
7c9f76c
be76b9a
 
 
 
9e9284b
 
 
 
 
 
 
 
 
 
 
 
b19267d
c915741
b19267d
c915741
3c7d95a
d84566a
c915741
7c9f76c
b19267d
3f666f4
b19267d
 
 
 
c915741
 
9778e08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c9f76c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9778e08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b829836
dd29b6f
b829836
 
 
 
 
 
dd29b6f
b829836
 
 
 
 
 
 
 
 
dd29b6f
b829836
 
 
 
 
 
dd29b6f
b829836
 
 
 
 
 
 
 
 
 
 
 
 
3f666f4
 
 
 
 
 
 
 
 
 
 
 
 
 
dd29b6f
 
 
 
 
 
 
 
 
 
 
 
 
 
3f666f4
 
 
 
 
 
 
 
 
 
 
 
 
 
dd29b6f
b829836
 
 
 
 
 
 
dd29b6f
b829836
 
 
 
 
 
 
 
 
 
 
dd29b6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b829836
 
 
 
 
 
dd29b6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
SixtyPical Syntax
=================

This is a test suite, written in [Falderal][] format, for the syntax of
the Sixtypical language, disgregarding execution, static analysis, etc.

Note that these example programs are intended to be syntactically correct,
but not necessarily sensible programs.

[Falderal]:     http://catseye.tc/node/Falderal

    -> Tests for functionality "Check syntax of SixtyPical program"

Rudimentary program.

    | define main routine {
    |     ld a, 0
    |     add a, 1
    | }
    = ok

Program with comments.

    | // Welcome to my program.
    | 
    | define main routine {
    |     ld a, 0
    |     add a, 1    // We are adding the thing.
    |     sub a, 1
    |     shl a
    |     shr a
    |     and a, 1
    |     or a, 1
    |     xor a, 1
    | }
    = ok

Hex literals.

    | define main routine {
    |     ld a, $ff
    |     add a, $01
    | }
    = ok

Syntax error.

    | define foo routine (
    |     ld a, 0
    |     add a, 1
    | )
    ? SyntaxError

Another syntax error.

    | byte glee
    | {
    |     ld a, 0
    |     add a, 1
    | }
    ? SyntaxError

Extern routines

    | define chrout routine
    |   inputs a
    |   trashes a
    |   @ 65490
    | 
    | define chrin routine
    |   outputs a
    |   trashes x
    |   @ 65487
    = ok

Preserved routine.

    | define main routine {
    |     ld a, $ff
    |     add a, $01
    | }
    | define foo preserved routine {
    |     ld a, 0
    |     add a, 1
    | }
    = ok

Trash.

    | define main routine {
    |     trash a
    |     trash n
    | }
    = ok

`nop`.

    | define main routine
    | {
    |     nop
    | }
    = ok

If with not

    | define foo routine {
    |     ld y, 0
    |     cmp y, 10
    |     if not z {
    |         inc y
    |         cmp y, 10
    |     }
    | }
    = ok

Repeat loop

    | define foo routine {
    |     ld y, 0
    |     repeat {
    |         inc y
    |         cmp y, 10
    |     } until z
    | }
    = ok

"While" loop

    | define foo routine inputs y {
    |     repeat {
    |         cmp y, 10
    |         if not z {
    |             inc y
    |         }
    |     } until z
    | }
    = ok

Repeat forever

    | define foo routine inputs y {
    |     repeat {
    |         inc y
    |     } forever
    | }
    = ok

Repeat with not

    | define foo routine inputs y {
    |     repeat {
    |         inc y
    |     } until not z
    | }
    = ok

Basic "open-faced for" loops, up and down.

    | byte table[256] tab
    | 
    | define foo routine trashes a, x, c, z, v {
    |     ld x, 0
    |     for x up to 15 {
    |         ld a, tab + x
    |     }
    |     ld x, 15
    |     for x down to 0 {
    |         ld a, tab + x
    |     }
    | }
    = ok

Other blocks.

    | byte table[256] tab
    | pointer ptr
    | 
    | define main routine trashes a, x, c, z, v {
    |     with interrupts off {
    |         save a, x, c {
    |             ld a, 0
    |         }
    |     }
    |     save a, x, c {
    |         ld a, 0
    |     }
    |     point ptr into tab {
    |         reset ptr 0
    |         ld a, [ptr] + y
    |     }
    | }
    = ok

User-defined memory addresses of different types.

    | byte byt
    | word wor
    | vector routine trashes a vec
    | byte table[2048] buf
    | pointer ptr
    | 
    | define main routine {
    | }
    = ok

Tables of different types and some operations on them.

    | byte table[256] many
    | word table[256] wmany
    | vector (routine trashes a) table[256] vmany
    | byte bval
    | word wval
    | 
    | define main routine {
    |     ld x, 0
    |     ld a, 0
    |     st off, c
    |     add a, many + x
    |     sub a, many + x
    |     cmp a, many + x
    |     and a, many + x
    |     or a, many + x
    |     xor a, many + x
    |     shl many + x
    |     shr many + x
    |     inc many + x
    |     dec many + x
    |     ld a, many + x
    |     st a, many + x
    |     copy wval, wmany + x
    |     copy wmany + x, wval
    | }
    = ok

Indexing with an offset in some tables.

    | byte table[256] many
    | word table[256] wmany
    | byte bval
    | word wval
    | 
    | define main routine {
    |     ld x, 0
    |     ld a, 0
    |     st off, c
    |     add a, many + 100 + x
    |     sub a, many + 100 + x
    |     cmp a, many + 100 + x
    |     and a, many + 100 + x
    |     or a, many + 100 + x
    |     xor a, many + 100 + x
    |     shl many + 100 + x
    |     shr many + 100 + x
    |     inc many + 100 + x
    |     dec many + 100 + x
    |     ld a, many + 100 + x
    |     st a, many + 100 + x
    |     copy wval, wmany + 100 + x
    |     copy wmany + 100 + x, wval
    | }
    = ok

The number of entries in a table must be
greater than 0 and less than or equal to 65536.

(In previous versions, a table could have at
most 256 entries.  They can now have more, however
the offset-access syntax can only access the
first 256.  To access more, a pointer is required.)

    | word table[512] many
    | 
    | define main routine
    |   inputs many
    |   outputs many
    |   trashes a, x, n, z
    | {
    |     ld x, 0
    |     copy 9999, many + x
    | }
    = ok

    | byte table[65536] many
    | 
    | define main routine
    |   inputs many
    |   outputs many
    |   trashes a, x, n, z
    | {
    |     ld x, 0
    |     copy 99, many + x
    | }
    = ok

    | byte table[65537] many
    | 
    | define main routine
    |   inputs many
    |   outputs many
    |   trashes a, x, n, z
    | {
    |     ld x, 0
    |     copy 99, many + x
    | }
    ? SyntaxError

    | word table[0] many
    | 
    | define main routine
    |   inputs many
    |   outputs many
    |   trashes a, x, n, z
    | {
    |     ld x, 0
    |     copy 9999, many + x
    | }
    ? SyntaxError

    | word table[48] many
    | 
    | define main routine
    |   inputs many
    |   outputs many
    |   trashes a, x, n, z
    | {
    |     ld x, 0
    |     copy 9999, many + x
    | }
    = ok

Typedefs of different types.

    | typedef byte octet
    | typedef octet table[256] twokay
    | typedef routine trashes a game_routine
    | vector game_routine start_game
    | 
    | define main routine {
    | }
    = ok

Can't have two typedefs with the same name.

    | typedef byte frank
    | typedef word frank
    | 
    | define main routine {
    | }
    ? SyntaxError

Constants.

    | const lives 3
    | const days lives
    | const w1 1000
    | const w2 word 0
    | 
    | typedef byte table[days] them
    | 
    | byte lark: lives
    | 
    | define main routine {
    |   ld a, lives
    | }
    = ok

Named constants can be used as offsets.

    | const lives 3
    | const w1 1000
    | 
    | byte table[w1] those
    | 
    | define main routine {
    |   ld y, 0
    |   ld a, those + lives + y
    | }
    = ok

Can't have two constants with the same name.

    | const w1 1000
    | const w1 word 0
    | 
    | define main routine {
    | }
    ? SyntaxError

Explicit memory address.

    | byte screen @ 1024
    | 
    | define main routine {
    |   ld a, 100
    |   st a, screen
    |   shl screen
    |   shr screen
    | }
    = ok

Initialized memory locations.

    | byte lives : 3
    | 
    | define main routine {
    |   ld a, lives
    |   st a, lives
    | }
    = ok

Cannot have both initial value and explicit address.

    | byte screen : 3 @ 1024
    | 
    | define main routine {
    |   ld a, lives
    |   st a, lives
    | }
    ? SyntaxError

User-defined locations of other types.

    | byte table[256] screen @ 1024
    | word r1
    | word r2 @ 60000
    | word r3 : 2000
    | 
    | define main routine {
    | }
    = ok

Initialized byte table, initialized with ASCII string.

    | byte table[32] message : "WHAT DO YOU WANT TO DO NEXT?"
    | 
    | define main routine {
    | }
    = ok

Can't initialize anything but a byte table with a string.

    | word message : "OUCH! WHAT DO YOU DO?"
    | 
    | define main routine {
    | }
    ? SyntaxError

Initialized byte table, initialized with list of bytes.

    | byte table[8] charmap : 0, 255, 129, 192, 0, 1, 2, 4
    | 
    | define main routine {
    | }
    = ok

Can't access an undeclared memory location.

    | define main routine {
    |     ld a, 0
    |     st a, lives
    | }
    ? SyntaxError

Can't define two memory locations with the same name.

    | byte lives
    | byte lives
    | 
    | define main routine {
    |     ld a, 0
    |     st a, lives
    | }
    ? SyntaxError

Can't shadow the name of a register or a flag.

    | byte a
    | 
    | define main routine {
    | }
    ? SyntaxError

    | byte z
    | 
    | define main routine {
    | }
    ? SyntaxError

Can't call routine that hasn't been defined.

    | define main routine {
    |     ld x, 0
    |     ld y, 1
    |     call up
    |     call up
    | }
    ? SyntaxError

But you can call a routine that is yet to be defined, further on.

    | define main routine {
    |     ld x, 0
    |     ld y, 1
    |     call up
    |     call up
    | }
    | define up routine {
    |     ld a, 0
    | }
    = ok

Can't define two routines with the same name.

    | define main routine {
    |     inc x
    |     inc y
    | }
    | define main routine {
    |     ld x, 0
    |     ld y, 1
    | }
    ? SyntaxError

Declaring byte and word table memory location.

    | byte table[256] tab
    | 
    | define main routine {
    |     ld x, 0
    |     ld y, 0
    |     ld a, tab + x
    |     st a, tab + y
    | }
    = ok

    | word one
    | word table[256] many
    | 
    | define main routine {
    |     ld x, 0
    |     copy one, many + x
    |     copy word 0, many + x
    |     copy many + x, one
    | }
    = ok

Declaring and calling a vector.

    | vector routine
    |   inputs a
    |   outputs x
    |   trashes a, x, z, n
    |   cinv @ 788
    | 
    | define foo routine {
    |     ld a, 0
    | }
    | define main routine {
    |     with interrupts off {
    |         copy foo, cinv
    |     }
    |     call cinv
    | }
    = ok

Only vectors can be decorated with constraints like that.

    | byte cinv
    |   inputs a
    |   outputs x
    |   trashes a, x, z, n
    |   @ 788
    | 
    | define main routine {
    | }
    ? SyntaxError

Constraints set may only contain labels.

    | vector routine
    |   inputs a
    |   outputs 200
    |   trashes a, x, z, n
    |   cinv @ 788
    | 
    | define foo routine {
    |     ld a, 0
    | }
    | define main routine {
    |     with interrupts off {
    |         copy foo, cinv
    |     }
    |     call cinv
    | }
    ? SyntaxError

A vector can name itself in its inputs, outputs, and trashes.

    | vector routine
    |   inputs cinv, a
    |   outputs cinv, x
    |   trashes a, x, z, n
    |   cinv @ 788
    | 
    | define foo routine {
    |     ld a, 0
    | }
    | define main routine {
    |     with interrupts off {
    |         copy foo, cinv
    |     }
    |     call cinv
    | }
    = ok

A routine can be copied into a vector before the routine appears in the program.
This is known as a "forward reference".  You are only allowed to make forward
references in the source of a `copy` instruction.

    | vector routine
    |   inputs cinv, a
    |   outputs cinv, x
    |   trashes a, x, z, n
    |   cinv @ 788
    | define main routine {
    |     with interrupts off {
    |         copy foo, cinv
    |     }
    |     call cinv
    | }
    | define foo routine {
    |     ld a, 0
    | }
    = ok

goto.

    | define foo routine {
    |     ld a, 0
    | }
    | define main routine {
    |     goto foo
    | }
    = ok

The label doesn't have to be defined yet at the point
in the program text where it is `goto`d.

    | define main routine {
    |     goto foo
    | }
    | define foo routine {
    |     ld a, 0
    | }
    = ok

Syntactically, you can `goto` a vector.

    | vector routine foo
    | 
    | define main routine {
    |     goto foo
    | }
    = ok

But you can't `goto` a label that never gets defined.

    | define main routine {
    |     goto foo
    | }
    ? SyntaxError

`goto` may only be the final instruction in a block.

    | define bar routine trashes x, z, n {
    |     ld x, 200
    | }
    | 
    | define main routine trashes x, z, n {
    |     goto bar
    |     ld x, 0
    | }
    ? Expected '}', but found 'ld'

Tables and pointers.

    | byte table[2048] buf
    | pointer ptr
    | pointer ptrb
    | byte foo
    | 
    | define main routine {
    |     point ptr into buf {
    |         reset ptr 0
    |         copy 123, [ptr] + y
    |         copy [ptr] + y, foo
    |         copy [ptr] + y, [ptrb] + y
    |     }
    | }
    = ok

Routines can be defined in a new style.

    | typedef routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |     routine_type
    | 
    | vector routine_type vec
    | 
    | define foo routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    | {
    |   inc x
    | }
    | 
    | define main routine
    |   outputs vec
    |   trashes a, z, n
    | {
    |     copy foo, vec
    | }
    = ok

    | typedef routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |     routine_type
    | 
    | vector routine_type vec
    | 
    | define foo routine_type
    | {
    |   inc x
    | }
    | 
    | define main routine
    |   outputs vec
    |   trashes a, z, n
    | {
    |     copy foo, vec
    | }
    = ok

Only routines can be defined in the new style.

    | define foo byte table[256]
    | 
    | routine main
    |   trashes a, z, n
    | {
    |     ld a, 0
    | }
    ? SyntaxError

Memory locations can be defined local to a routine.

    | define foo routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   static byte t : 0
    |   local word w
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    | 
    | define main routine
    |   trashes a, x, z, n
    |   static byte t : 0
    |   local word w
    | {
    |   ld x, t
    |   call foo
    | }
    = ok

Local static memory locations must always be given an initial value.

    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   static byte t
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    ? SyntaxError

Local static memory locations may not be given an address.

    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   static byte t @ 1024
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    ? SyntaxError

Local dynamic memory locations may not be given an initial value.

    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   local byte t : 10
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    ? SyntaxError

Local dynamic memory locations may be given an address.

    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   local byte t @ 1024
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    = ok

Name of a local cannot shadow an existing global or local.

    | byte t
    | 
    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   static byte t : 10
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    ? SyntaxError

    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   static byte t : 10
    |   static byte t : 20
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    ? SyntaxError

    | byte t
    | 
    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   local byte t
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    ? SyntaxError

    | define main routine
    |   inputs x
    |   outputs x
    |   trashes z, n
    |   local word w
    |   local word w
    | {
    |   st x, t
    |   inc t
    |   ld x, t
    | }
    ? SyntaxError

Since the names of locals are lexically local to a routine, they cannot
appear in the inputs, outputs, trashes list of the routine.

    | define main routine
    |   inputs t
    |   static byte t : 0
    | {
    |   inc t
    | }
    ? SyntaxError

    | define main routine
    |   outputs t
    |   static byte t : 0
    | {
    |   inc t
    | }
    ? SyntaxError

    | define main routine
    |   trashes t
    |   static byte t : 0
    | {
    |   inc t
    | }
    ? SyntaxError

    | define main routine
    |   inputs t
    |   local byte t
    | {
    |   inc t
    | }
    ? SyntaxError

    | define main routine
    |   outputs t
    |   local byte t
    | {
    |   inc t
    | }
    ? SyntaxError

    | define main routine
    |   trashes t
    |   local byte t
    | {
    |   inc t
    | }
    ? SyntaxError