Share via


IParseSink::Parameter Method

Called for each parameter separator, for example, ",".

HRESULT Parameter ( 
   long line,
   long idx
);

Parameters

  • line
    [in] Line position of the new parameter character for the parameter list, for example, ",".

  • idx
    [in] Index position of the new parameter character.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

This method is called when a new parameter is started, for example ",".

Call this method only if your IBabelService::ParseSource Method implementation is called with the ParseReason Enumeration value of ReasonMethodTip in the reason parameter. You should call IParseSink::Parameter once for each new parameter separator that is found in the span of text passed to you in the text parameter of IBabelService::ParseSource Method.

The Default Babel Implementation in the Language Service Package, this method is called from the StdService::parameter method that in turn can be called from within your grammar file. The Example in this topic shows how the parameter method is called when a method parameter list is parsed.

For a more detailed example of using the StdService::parameter method, see How to: Enable Parameter Info ToolTips.

Example

This is a fragment from the default parser.y grammar file that is created using the Visual Studio Language Service Wizard. This fragment shows how a method parameter list is parsed, specifically, how the arguments are handled with calls to the parameter method on the language service (g_service). The parameter method eventually calls the IParseSink::Parameter method.

ParenArguments
    : StartArg EndArg                { g_service->matchPair($1,$2); } 
    | StartArg Arguments1 EndArg     { g_service->matchPair($1,$3); }
    | StartArg Arguments1 error      { g_service->endParameters(@3);
                                       g_service->expectError( "unmatched parenthesis", ")" ); }
    ;

StartArg
    : '('                       { g_service->startParameters($1); }
    ;

EndArg
    : ')'                       { g_service->endParameters($1); }
    ;

Arguments1
    : Expr ',' { g_service->parameter($2); } Arguments1
    | Expr
    ;

See Also

Concepts

How to: Enable Parameter Info ToolTips

Reference

IParseSink Interface

ParseReason Enumeration

IBabelService::ParseSource Method