next up previous
Next: Operator.d Up: Type Analysis Previous: Variable declarations


Procedure and function declarations

Procedure and function declarations[29]:
SYMBOL ProcHead INHERITS TypeDenotation, OperatorDefs END;
SYMBOL FuncHead INHERITS TypeDenotation, OperatorDefs END;
SYMBOL ProcBody INHERITS TypeDenotation, OperatorDefs END;
SYMBOL FuncBody INHERITS TypeDenotation, OperatorDefs END;

SYMBOL Formals  INHERITS OpndTypeListRoot END;
SYMBOL FmlIdDef INHERITS OpndTypeListElem END;

RULE: ProcHead ::= Formals COMPUTE
  ProcHead.GotType=
    AddTypeToBlock(
      ProcHead.Type,
      ProcTypes,
      Formals.OpndTypeList);
  ProcHead.GotOper=
    ListOperator(ProcHead.Type,NoOprName,Formals.OpndTypeList,voidType);
END;

RULE: ProcBody ::= Formals ';' block COMPUTE
  ProcBody.GotType=
    AddTypeToBlock(
      ProcBody.Type,
      ProcTypes,
      Formals.OpndTypeList);
  ProcBody.GotOper=
    ListOperator(ProcBody.Type,NoOprName,Formals.OpndTypeList,voidType);
END;

RULE: FuncHead ::= Formals ':' TypIdUse COMPUTE
  FuncHead.GotType=
    AddTypeToBlock(
      FuncHead.Type,
      FuncTypes,
      ConsDefTableKeyList(TypIdUse.Type,Formals.OpndTypeList));
  FuncHead.GotOper=
    ListOperator(FuncHead.Type,NoOprName,Formals.OpndTypeList,TypIdUse.Type);
END;

RULE: FuncBody ::= Formals ':' TypIdUse ';' block COMPUTE
  FuncBody.GotType=
    AddTypeToBlock(
      FuncBody.Type,
      FuncTypes,
      ConsDefTableKeyList(TypIdUse.Type,Formals.OpndTypeList));
  FuncBody.GotOper=
    ListOperator(FuncBody.Type,NoOprName,Formals.OpndTypeList,TypIdUse.Type);
END;
This macro is defined in definitions 29, 31, 32, and 33.
This macro is invoked in definition 1.

Property definitions[30]:
ProcTypes;
FuncTypes;
This macro is defined in definitions 11, 19, 24, 30, 34, and 38.
This macro is invoked in definition 7.

Functions with no arguments are invoked without an argument list. Since there is no syntactic clue, the ``call'' must be treated as a coercion.

Procedure and function declarations[31]:
RULE: FuncHead ::= ':' TypIdUse COMPUTE
  FuncHead.GotType=
    AddTypeToBlock(
      FuncHead.Type,
      FuncTypes,
      SingleDefTableKeyList(TypIdUse.Type));
  FuncHead.GotOper=Coercible(NoOprName,FuncHead.Type,TypIdUse.Type);
END;

RULE: FuncBody ::= ':' TypIdUse ';' block COMPUTE
  FuncBody.GotType=
    AddTypeToBlock(
      FuncBody.Type,
      FuncTypes,
      SingleDefTableKeyList(TypIdUse.Type));
  FuncBody.GotOper=Coercible(NoOprName,FuncBody.Type,TypIdUse.Type);
END;
This macro is defined in definitions 29, 31, 32, and 33.
This macro is invoked in definition 1.

Procedure and function declarations[32]:
CHAIN Forward: VOID;

CLASS SYMBOL RootType COMPUTE
  CHAINSTART HEAD.Forward = "yes";
END;

RULE: Decl ::= 'procedure' PrcIdDef ProcBody COMPUTE
  .Type=GetTypeOf(PrcIdDef.Key,NoKey) <- Decl.Forward;
  PrcIdDef.Type=IF(EQ(.Type,NoKey),ProcBody.Type,.Type);
  ProcBody.Forward=PrcIdDef.Type;
END;

RULE: Decl ::= 'function'  FncIdDef FuncBody COMPUTE
  .Type=GetTypeOf(FncIdDef.Key,NoKey) <- Decl.Forward;
  FncIdDef.Type=IF(EQ(.Type,NoKey),FuncBody.Type,.Type);
  FuncBody.Forward=FncIdDef.Type;
END;
This macro is defined in definitions 29, 31, 32, and 33.
This macro is invoked in definition 1.

Procedure and function declarations[33]:
TREE SYMBOL FmlIdDef INHERITS TypedDefId      END;
TREE SYMBOL PrcIdDef INHERITS TypedDefId      END;
TREE SYMBOL FncIdDef INHERITS TypedDefId      END;

RULE: Formal ::= FrmlIds ':' type COMPUTE
  FrmlIds.Type=type.Type;
END;

RULE: Formal ::= 'var' FrmlIds ':' type COMPUTE
  FrmlIds.Type=type.Type;
END;

RULE: Formal ::= 'procedure' FmlIdDef ProcHead COMPUTE
  FmlIdDef.Type=ProcHead.Type;
END;

RULE: Formal ::= 'function' FmlIdDef FuncHead COMPUTE
  FmlIdDef.Type=FuncHead.Type;
END;
This macro is defined in definitions 29, 31, 32, and 33.
This macro is invoked in definition 1.

Property definitions[34]:
absKey      -> TypeOf={absType};
arctanKey   -> TypeOf={arctanType};
chrKey      -> TypeOf={chrType};
cosKey      -> TypeOf={cosType};
disposeKey  -> TypeOf={disposeType};
eofKey      -> TypeOf={eofType};
eolnKey     -> TypeOf={eolnType};
expKey      -> TypeOf={expType};
getKey      -> TypeOf={getType};
inputKey    -> TypeOf={textType};
lnKey       -> TypeOf={lnType};
newKey      -> TypeOf={newType};
oddKey      -> TypeOf={oddType};
ordKey      -> TypeOf={ordType};
outputKey   -> TypeOf={textType};
predKey     -> TypeOf={predType};
putKey      -> TypeOf={putType};
readKey     -> TypeOf={readType};
readlnKey   -> TypeOf={readlnType};
resetKey    -> TypeOf={resetType};
rewriteKey  -> TypeOf={rewriteType};
roundKey    -> TypeOf={roundType};
sinKey      -> TypeOf={sinType};
sqrKey      -> TypeOf={sqrType};
sqrtKey     -> TypeOf={sqrtType};
succKey     -> TypeOf={succType};
truncKey    -> TypeOf={truncType};
writeKey    -> TypeOf={writeType};
writelnKey  -> TypeOf={writelnType};

absType     -> IsType={1};
arctanType  -> IsType={1};
chrType     -> IsType={1};
cosType     -> IsType={1};
disposeType -> IsType={1};
expType     -> IsType={1};
getType     -> IsType={1};
lnType      -> IsType={1};
newType     -> IsType={1};
oddType     -> IsType={1};
ordType     -> IsType={1};
predType    -> IsType={1};
putType     -> IsType={1};
readType    -> IsType={1};
readlnType  -> IsType={1};
resetType   -> IsType={1};
rewriteType -> IsType={1};
roundType   -> IsType={1};
sinType     -> IsType={1};
sqrtType    -> IsType={1};
sqrType     -> IsType={1};
succType    -> IsType={1};
truncType   -> IsType={1};
writeType   -> IsType={1};
writelnType -> IsType={1};
This macro is defined in definitions 11, 19, 24, 30, 34, and 38.
This macro is invoked in definition 7.


next up previous
Next: Operator.d Up: Type Analysis Previous: Variable declarations
2008-08-29