How to get ReportError to register an error when the AST node already has one

SyntaxEditor for WPF Forum

Posted 1 year ago by Andrew Hollom
Version: 18.1.0671
Avatar

Hello,

I am implementing a language that generates warnings and errors during its semantic analysis phase, and it appears that once an AST node has an error or warning, then it is not possible to log another. My problem is that I have logged a warning for a node, but later analysis would like to also report an error for that same node, but it is not getting logged. This is causing problems for the synthesis phase, which thinks there are only warnings when there is actually a problem that should stop code generation from even starting.

Could you please advise on how best to overcome this?

Many thanks,

Andrew.

Comments (3)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Andrew,

Yes that functionality is by design.  It only reports the first parse error that is reported for an offset.  If we didn't have that, then a single typing mistake could trigger a lot of parse errors at the same offset and the list of those parse errors to the end user would lose its effectiveness due to there being so many.  Visual Studio also only shows the first one.

The functionality that does that is built into the core ParserState.ReportError method.  Would you like us to add an optional parameter to the ReportError(IParseError) method that says whether to overwrite any existing parse error at the same offset?


Actipro Software Support

Posted 1 year ago by Andrew Hollom
Avatar

Hello,

I understand that it is by design, and i do not want to log multiple errors to a given AST node, so recording only the first logged error is fine by me. What I am having trouble with is that once a warning, i.e. not an error, has been logged, then a subsequent error will effectively be ignored, which is bad for the reason I explained in my earlier post. The functionality I would like is that an error overwrites a warning, as it is more important, but warnings should not overwrite errors, as they are less improtant. You could apply a simliar precedence-type logic with warnings and messages too.

I hope I've made myself clear and am not being unreasinable in my request. An optional parameter would be a solution of sorts, as it would allow me to decide my own precedence for diagnostics (I prefer not to call them errors, as I log warnings too) based in the ParseErrorLevel passed.

For some reason, the Reply button in your reply didn't work, hence the additional comment rather than a direct reply.

[Modified 1 year ago]

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Andrew,

Ok the priority idea sounds good.  Can you please write our support address and reference this thread?  We'll send you a preview build with the code update to test and make sure it's working properly for your scenario.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.