Tutorial on Name Analysis



Allmost all languages have certain identifiers that are predefined
for any program. This facility is demonstrated by introducing
typed variable declarations to our language:
Predef.con[11]==
Declaration: 'var' VarDecls ';'.
VarDecls: VarDecl // ','.
VarDecl: TypeUseIdent DefIdent.
TypeUseIdent: Ident.
This macro is attached to a product file.
The type of a declared variable is given by a TypeUseIdent .
A TypeUseIdent has the same computational roles which we associated with
applied identifier occurrences, except that it is not checked for
being defined since we assume that only predefined type
identifiers are used:
Predef.lido[12]==
SYMBOL TypeUseIdent INHERITS IdUseEnv, IdentOcc END;
This macro is attached to a product file.
The technique for predefining identifiers is provided by the
library modules PreDefine and PreDefId , see See Predefined Identifiers of Specification Module Library: Name Analysis.
PreDefine is instantiated with the Ident symbol
name as generic parameter.
PreDefId is instantiated with the file name Predef.d .
That file contains a sequence of macro calls, like
PreDefKey ("int", intKey) .
Each introduces a string and the name of a key.
The identifier is then bound to that key
in the outermost environment of each program.
Those Keys could be used in computations, e.g. for type checking
(We do not make use of this facility here.)
Predef.specs[13]==
$/Name/PreDefine.gnrc+referto=Ident:inst
$/Name/PreDefId.gnrc+referto=(Predef.d):inst
This macro is attached to a product file.
Predef.d[14]==
PreDefKey ("int", intKey)
PreDefKey ("real", realKey)
PreDefKey ("bool", boolKey)
PreDefKey ("true", trueKey)
PreDefKey ("false", falseKey)
This macro is attached to a product file.



|