Error Reporting Across Contiguous Tokens

SyntaxEditor for WPF Forum

The latest build of this product (v24.1.3) was released 1 month ago, which was before this thread was created.
Posted 14 days ago by Rick - Developer, Visual Software Systems LLC
Version: 24.1.3
Avatar

In my grammer I can have multi-node names and functions such as 'obj.prop.subprop' and 'func(param)' where each node in the name, the periods and paranthesis are individual tokens.  When I'm doing my final edits in the root production's onComplete event and find an error with a multi-node name or function, I need to tag the entire term as in error (red squiggles) not just one of its nodes, for example 'obj'.  The ReportError methods only take a single token and I can't modify a token, say for the 'obj' node, so that the entire name is tagged as in error. Is there a native way to accomplish this or do I need to subclass TokenBase so I can construct a token that spans the entire name?  Thanks.

Comments (2)

Answer - Posted 14 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rick,

The IParserState.ReportError method has multiple overloads.  The overload that accepts an IToken simply gets the position range of the IToken and assigns that and the specified description to the ParseError object that is created. 

Instead of using that overload, you could create your own ParseError and pass it the position range of the entire name.  Then call the ReportError overload that has the IParseError parameter.


Actipro Software Support

Posted 13 days ago by Rick - Developer, Visual Software Systems LLC
Avatar

That worked perfectly.  Thank you.

Add Comment

Please log in to a validated account to post comments.