Error handeling question

SyntaxEditor for WPF Forum

Posted 3 years ago by Eyal Lefler
Version: 16.1.0635
Avatar

Hello,

We have wrote a custom language with your SyntaxEditor.

The "root" statements can be functions or member variables (similar to a c# class).

If a user types an if statement or a return statement outside a function, the parser stops parsing and the error "Parsing completed before reaching document end" appears.

Instead - I want the parser to continue to the next membe variable\function declaration, and I want to display an error about the misplaced  return statement, for example: "Expected function declaration or member variable declaration".

How can I achieve that ?

Thanks,

Sharon

Comments (1)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sharon,

If you take a look at our LL(*) Parser Framework documentation topic "Callbacks and Error Handling" and the walkthough topic right after that, both of those explain in detail how to handle syntax errors and continue parsing forward as appropriate when one is detected.  By default, a syntax error will bubble up and stop parsing as you saw.  But by intelligently handling errors you can do things like report problems with custom descriptions, skip over tokens until the next one that starts valid code again, and can continue on parsing. 


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.