IParseSink::AddExtern Method
Add an external scope for the given span of text.
HRESULT AddExtern (
long startLine,
long startIdx,
long endLine,
long endIdx,
IScope* scope
);
Parameters
startLine
[in] Starting line of the item to add scope for.startIdx
[in] Starting index of the item (that is, the enclosing lexical context) in the starting line. The line index is zero-based.endLine
[in] Ending line of the item to add scope for.endIdx
[in] Ending index of the item in the ending line. The line index is zero-based.scope
[in] The external scope, that is, the symbol tree, which contains the item. For more information, see the IScope Interface.
Return Value
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Remarks
This method is used for include files or import modules. A scope can, for example, be retrieved using the IBabelProject::SearchFile Method or the IBabelPackage::LoadScope Method. The AddExtern method can be used to load any scope, regardless of the language that it supports.
To obtain an external scope using the IBabelPackage::LoadScope method, do the following:
Call the IParseSink::GetPackage Method method.
An IBabelPackage Interface object is returned.
Call the IBabelPackage::LoadScope Method method, specifying the file name and project that contains the scope.
Use the following procedure to obtain the file name and project information:
Call the IParseSink::GetProject Method method to return a pointer to the project.
A pointer to the IBabelProject Interface object is returned. Use this pointer for the project parameter in the IBabelPackage::LoadScope method.
Call the IParseSink::GetFileName Method method to return the file name.
A string containing the file name is returned. Use this string for the fileName parameter in the IBabelPackage::LoadScope method.
The external IScope Interface object is returned from the IBabelPackage::LoadScope method. Use this value for the scope parameter in the AddExtern method.
The Default Babel Implementation in the Language Service Package, this method is called from the StdService::addExtern method that in turn can be called from within your grammar file. The example in the IBabelPackage::LoadScope method shows how this looks in a parser.y grammar file. See How to: Add Import Chasing for more details on using the StdService::addExtern method.