next up previous
Next: Record types Up: The Pascal type model Previous: Subrange types

Array types

Array types[14]:
CLASS arrayType(indexType,elementType) BEGIN
  OPER
    arrayaccess(arrayType,indexType): elementType;

/* FIXME: Array types can only be compared if they are packed 1..x of char
 **/
  COERCION (arrayType): stringType;
END;

OPER
  stringAccess(stringType): charType;
  stringcmp(stringType,stringType): boolType;

INDICATION
  arrayAccess: arrayaccess, stringAccess;
  equal: stringcmp;
  lsgt: stringcmp;
  less: stringcmp;
  greater: stringcmp;
  lessequal: stringcmp;
  greaterequal: stringcmp;
This macro is invoked in definition 3.

Establish a user-defined type[15]:
RULE: TypeDenoter ::=  'array' '[' type ']' 'of' type COMPUTE
  TypeDenoter.GotOper=
    InstClass2(arrayType,TypeDenoter.Type,type[1].Type,type[2].Type);
END;
This macro is defined in definitions 4, 10, 13, 15, 16, 18, 21, and 23.
This macro is invoked in definition 1.



2008-08-29