Nasty Example SPL Programs
I've written a few example test programs to debug various edge cases whilst writing a compiler for my coursework at University, and I thought I've post them here to help others out. As this coursework is ongoing I'm not going to say anything else, but I hope that these help someone else out :-)
Anyone posting coursework compiler code here will have it deleted (but additional example SPL programs are welcome). In addition, I make no guarantees that these programs are even valid SPL that should compile.
Nasty A
NastyA:
DECLARATIONS
a OF TYPE INTEGER;
CODE
READ(a);
WRITE(a);
WRITE(45, 'c', 5.68249)
ENDP NastyA.
Nasty B
NastyB:
DECLARATIONS
i, toggle, step, limit OF TYPE INTEGER;
CODE
1 -> toggle;
1 -> step;
10 -> limit;
FOR i IS 1 BY step TO limit DO
IF toggle = 1 THEN
-1 -> step;
-1 -> toggle;
-10 -> limit
ENDIF;
WRITE(i);
NEWLINE;
WRITE(toggle);
NEWLINE;
WRITE(step);
NEWLINE;
NEWLINE
ENDFOR;
NEWLINE
ENDP NastyB.
Nasty C
NastyC:
DECLARATIONS
a,b,c OF TYPE INTEGER;
d,e,f,g OF TYPE REAL;
CODE
5 + 8 -> a;
4.5 + 6.8 -> d;
WRITE(a);
NEWLINE;
WRITE(d);
NEWLINE;
WRITE((8 - 4));
NEWLINE
ENDP NastyC.