Posted 15 years ago
by Phil Devaney
-
Senior Software Engineer,
Serck Controls Ltd
Version: 9.1.0503
I have a SyntaxLanguage that uses a DataflowLexer, and I am currently trying to implement Completion Lists. I need to know a bit of context to determine what to display in the completion list, so I call:
however token.Key is null, and I have no way of tying token.ID to a particular token type.
I found Bill's post on MSDN about token descriptions in MGrammer (http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/1d740ec6-e3d9-493f-9152-064525d1aa9d) and came up with this method:This seems to work if I add Description attributes to the tokens in my grammar definition, but its a bit convoluted. Do you have any plans/guidance for how to handle this? It would be nice to use integer comparisons instead of string comparisons - perhaps a tool that generates a class derived from DynamicParser tied to a particular parser, with public constants for each token type.
var token = view.GetReader().ReadTokenReverse();
I found Bill's post on MSDN about token descriptions in MGrammer (http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/1d740ec6-e3d9-493f-9152-064525d1aa9d) and came up with this method:
private static string GetTokenDesc( ActiproSoftware.Text.Lexing.IToken token )
{
foreach ( object o in Expression.Parser.GetTokenInfo( token.Id ) )
{
var descAttr = System.Dataflow.GraphNode.LookupGraph( "Description", o );
if ( descAttr != null )
return System.Dataflow.GraphNode.LookupGraphArgument( descAttr ) as string;
}
return null;
}