Assignment 4

The Operational Semantics of Type Compatibility

Goals

To understand the differences between pure name and pure structure compatibility of types and to implement type checking in Rigal accordingly.

Procedure

Working with the parser/interpreter posted on the web site (www.cs.nmsu.edu/~rth/cs/cs471/SimpleInterpreterDeclarations.rig) modify the interpreter code to implement:

  1. pure name compatibility
  2. pure structure compatibility

Use the following simple programs to test your code (note the comments are not part of the program):

 

t1=INTEGER;

x:INTEGER;

y:t1;

x=1;// name: yes, structure: yes

y=2;// name: yes, structure: yes

x=y// name: no, structure: yes

 

t1=RECORD x:INTEGER;y:REAL END;

t2=RECORD a:INTEGER;b:REAL END;

t3=RECORD c:INTEGER;d:INTEGER END;

x1:t1;

x2:t1;

y:t2;

z:t3;

x1=x2;// name: yes, structure: yes

x1=y;// name: no, structure: yes

y=z// name: no, structure: no

 

Hints

Grading

Total 50 points. Partial credit will be available for answers that are along the right lines.

Due Date

October 18th before 5:00pm.