![]() |
![]() |
![]() |
General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
![]() |
![]() |
Tutorial on Type AnalysisType Definitions
We now introduce type definitions to our language.
A name can be defined for any The following concrete productions are added: TypeDef.con[40]== Declaration: 'type' TypeDenoter TypeDefIdent ';'. TypeDefIdent: Ident. This macro is attached to a product file. Here is an example program with type definitions. It makes use of the facility that identifiers may be defined after their uses: TypedefExamp[41]== begin var tt rv; type t tt; type record int i, bool b, real r end t; var int j, bool c, real s; var t rt; j = rv.i; c = rv.b; s = rv.r; rt = rv; end This macro is attached to a product file.
A type definition introduces a new name for a type given
by the
Hence, in the following specification we only have to characterize
a defining occurrence of a type identifier by the corresponding
roles of the name analysis module and those for a defining
occurrence of a type identifier ( TypeDef.lido[42]== SYMBOL TypeDefIdent INHERITS ChkUnique, IdDefScope, IdentOcc, TypeDefDefId, ChkTypeDefDefId END; RULE: Declaration ::= 'type' TypeDenoter TypeDefIdent ';' COMPUTE TypeDefIdent.Type = TypeDenoter.Type; END; This macro is attached to a product file. If we wanted to deviate from the above rules for name equality in case of certain types, we would use the same specification, and would augment the function that checks for equality of type by suitable comparisons, e. g. compare the structure of two record types.
|