next up previous
Next: Determining the meaning of Up: Applied occurrences of names Previous: Ambiguous names

Qualified names

All qualified names are represented by the single nonterminal Name.

In some contexts, an initial segment of the qualified name is a package name. We consider a package name to be a single symbol consisting of the intial segment of the qualified name including the separating dots. Thus we must be able to convert any initial segment of a qualified name to a single symbol. Our strategy is to accumulate the identifiers making up the qualified name as a list of string table indices in reverse order:

Qualified names[26]:
ATTR Ids: intList;

TREE SYMBOL InhBaseId INHERITS IdentOcc END;

RULE: QualInhName ::= InhBaseId COMPUTE
  QualInhName.Ids=SingleintList(InhBaseId.Sym);
END;

TREE SYMBOL InhQualId INHERITS IdentOcc END;

RULE: QualInhName ::= QualInhName '.' InhQualId COMPUTE
  QualInhName[1].Ids=ConsintList(InhQualId.Sym,QualInhName[2].Ids);
END;
This macro is invoked in definition 21.

Instantiate required modules[27]:

$/Adt/List.gnrc +instance=int :inst
This macro is defined in definitions 3, 6, 7, 27, 30, and 36.
This macro is invoked in definition 1.

Any sublist of this list easily be converted to a string by a recursive function that reassembles the components in the proper order:

int FullyQualifiedName(intList rep)[28]:
/* Convert a qualified name to a single symbol
 *   On entry-
 *     rep=list representing the initial segment to be converted
 *   On exit-
 *     FullyQualifiedName=string table index of the symbol
 ***/
{ if (rep) {
    MakeFQName(rep);
    obstack_1grow(Csm_obstk, '\0');
    CsmStrPtr = (char *)obstack_finish(Csm_obstk);
    return MakeName(CsmStrPtr);
  } else
    return 0;
}
This macro is invoked in definition 39.

void MakeFQName(intList rep)[29]:
/* Build a string by reversing a list
 *   On entry-
 *     rep=list to be reversed and converted
 *   On exit-
 *     Csm_obstk contains the converted string, unterminated
 ***/
{ char *temp;

  intList tail = TailintList(rep);
  if (tail != NULLintList) {
    MakeFQName(tail);
    obstack_1grow(Csm_obstk, '.');
  }
  temp = StringTable(HeadintList(rep));
  obstack_grow(Csm_obstk, temp, strlen(temp));
}
This macro is invoked in definition 39.

Instantiate required modules[30]:

$/Tech/MakeName.gnrc +instance=Identifier :inst
This macro is defined in definitions 3, 6, 7, 27, 30, and 36.
This macro is invoked in definition 1.

Applied occurrences of names[31]:
ATTR Key: DefTableKey;

RULE: PackageName ::= QualInhName COMPUTE
  PackageName.Ids=QualInhName.Ids;
  PackageName.Sym=QualInhName.Sym;
END;

RULE: InhName ::= QualInhName COMPUTE
  InhName.Ids=QualInhName.Ids;
  InhName.Sym=QualInhName.Sym;
  InhName.Key=QualInhName.Key;
  InhName.Type=TransDefer(QualInhName.Type);
END;
This macro is defined in definitions 21, 31, 32, 33, and 34.
This macro is invoked in definition 2.


next up previous
Next: Determining the meaning of Up: Applied occurrences of names Previous: Ambiguous names
2008-09-11