what offset to pass to SyntaxError constructor?

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Kelly Leahy - Software Architect, Milliman
Version: 4.0.0247
I've written my own recursive descent parser, rather than using the parser generator, as I was having trouble understanding how to roll good error recovery into the generated parser, and also so that I could tweak the performance of the parser.

It works very well, except that when I try to report an error that is due to early termination of the parsed text, the error doesn't show up in the editor view (no wavy lines). I know that the parser generator's error identification was able to identify errors due to early termination of the text and obviously reported them (I saw the wavy lines).

What I've been doing is:

formula.SyntaxErrors.Add(new SyntaxError(lexicalParser.LookAheadToken.TextRange, "..."))

but this works beautifully everywhere EXCEPT on the "EndDocument" token.

Is there a different way I need to report errors when they are identified only at the EndDocument token?


Kelly Leahy Software Architect Milliman, USA

Comments (2)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Kelly,

That is a bug that we have on our TODO list. Right now with how the indicators/rendering procedures work, a span indicator at the end of the document isn't possible. We need to alter how some of the code works to enable this, but it is on the TODO list.

Actipro Software Support

Posted 17 years ago by Kelly Leahy - Software Architect, Milliman
Just FYI for anyone reading this thread...

My workaround was:
        private TextRange GetLookaheadErrorLoc()
            if (lexicalParser.LookAheadToken.ID == FormulaTokenID.DocumentEnd)
                if(lexicalParser.Token == null)
                    return new TextRange(0, 1);
                    return new TextRange(lexicalParser.Token.EndOffset, lexicalParser.Token.EndOffset + 1);
                return lexicalParser.LookAheadToken.TextRange;

Kelly Leahy Software Architect Milliman, USA

The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.