Using your sample app with the math expressions, there is an error alias for the primary expression. This works great! However, in certain situations the error message we want to display to the user is not the default "Expression expected."
int a= // expression expected here is good int a = 5 + // expression expected here is good int a = contents( // here, the user can use a location identifier or a loc() function.
We have opted to set our grammer to the following for the contents function:
contentsFunction.Production = @contents + @openParenthesis + mathExpression["locationExp"] + @closeParenthesis.OnErrorContinue() > Ast<ContentsNode>() .SetProperty(x => x.Location, AstFrom("locationExp"));
We have many other functions that have the same thing. We have chosen to use the default math expression, so if the user does type in something like:
int a = contents(loc1+5*2)
They will get only 1 error over the loc1+5*2, instead of many errors.
We have many functions where we have chosen to use an expression here, but would like to report a different error to the user. We currently have a hack in place that is not clean, but we have a error callback on the mathPrimaryExpression, and got some hand-jammed code to report a different error instead of the default "Expression expected".
Is there a better way to report more specific errors on the mathExpression at a higher level when the mathPrimaryExpression has an error alias?
Any help would be greatly appreciated! Thanks!