General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
Tutorial on Name AnalysisA Second Name SpaceThe scope rules of some languages define several distinct name spaces, i.e. the identifier occurrences in one name space do not affect bindings in another name space. In C, for example, variable identifiers and label identifiers belong to different name spaces. We demonstrate that aspect by introducing a special kind of variable to our language. Such variables are set by a special statement, and accessed by special operands. Hence, the identifier occurrences are syntactically distinguished from identifier occurrences of the name space used so far. Flat.con[18]== Statement: 'set' CtrlVarUse 'to' Expression ';'. Operand: 'use' CtrlVarUse. CtrlVarUse: Ident. This macro is attached to a product file. We use another instantiation of the scope rule library module to specify the scope rules for the second name space, and require test output for it: Flat.specs[19]== $/Name/AlgScope.gnrc+instance=CtrlVar:inst $/Name/ShowBinding.gnrc+instance=CtrlVar:inst This macro is attached to a product file.
The
We demonstrate another variant of scope rules for our
new Flat.lido[20]== SYMBOL Source INHERITS CtrlVarRangeScope END; SYMBOL CtrlVarUse INHERITS CtrlVarIdDefScope, IdentOcc END; This macro is attached to a product file.
Since we allow the use of
|