|
![]() |
General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
Tutorial on Name AnalysisScopes being Properties of ObjectsCertain language constructs require that a set of bindings, i.e. a scope is associated as a property of an object. We demonstrate this facility by introducing modules to our language: ScopeProp.con[21]== Declaration: 'module' DefIdent ModBlock ';'. ModBlock: Compound. Operand: ModUseIdent '::' QualIdent. ModUseIdent: Ident. QualIdent: Ident. This macro is attached to a product file.
Any object A library module (see Scopes Being Properties of Objects of Specification Module Library: Name Analysis) provides computational roles for scopes being associated with object keys: ScopeProp.specs[22]== $/Name/AlgScopeProp.gnrc:inst This macro is attached to a product file.
The scope of the module body, with its local definitions,
is associated as a property with the key representing the module.
The role ScopePropDef.lido[23]== SYMBOL ModBlock INHERITS RangeScopeProp END; RULE: Declaration ::= 'module' DefIdent ModBlock ';' COMPUTE ModBlock.ScopeKey = DefIdent.Key; END; This macro is attached to a product file.
In binding a qualified identifier occurrence,
We assume that In addition, the roles used for applied identifier occurrences are associated. ScopePropUse.lido[24]==
RULE: Expression ::= ModUseIdent '::' QualIdent COMPUTE
QualIdent.Scope = GetScope (ModUseIdent.Key, NoEnv)
<- INCLUDING RootScope.GotScopeProp;
END;
SYMBOL ModUseIdent INHERITS
ChkModUseIdent,
IdUseEnv, ChkIdUse, IdentOcc
END;
SYMBOL QualIdent INHERITS
IdUseScopeProp,
ChkIdUse, IdentOcc
END;
CLASS SYMBOL ChkModUseIdent COMPUTE
IF (AND (NE (THIS.Key, NoKey),
EQ (GetScope (THIS.Key, NoEnv), NoEnv)),
message (FATAL, CatStrInd ("module or class identifier required: ",
THIS.Sym), 0, COORDREF))
<- INCLUDING RootScope.GotScopeProp;
END;
This macro is attached to a product file.
|