Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover parsing state on errors. #199

Open
rhdunn opened this issue Jun 24, 2016 · 2 comments
Open

Recover parsing state on errors. #199

rhdunn opened this issue Jun 24, 2016 · 2 comments

Comments

@rhdunn
Copy link

rhdunn commented Jun 24, 2016

If the intellij-xquery parser encounters an error, the code that follows the error point is not parsed correctly. This has the following effects:

  1. Subsequent errors are masked by the starting error -- this is worse if the initial error is due to a problem with the xquery parser (like issue Valid expressions of the form ... < (...) are reported as errors. #198).
  2. Information in the module such as functions that follow the error is not processed -- this causes calls to those functions to be incorrectly reported as errors.
  3. Automatic indentation is broken when entering code after the point of the error.

It would be helpful for the parser to recover as close as possible to the next valid start/recover point. I understand that this will be complex.

At the basic level, this should be able to recover to the start of the next statement such as if, for, let, and declare function statements.

@ligasgr
Copy link
Owner

ligasgr commented Jun 24, 2016

Unfortunately with the very context-sensitive nature of the language and with the fact that in Main Module you can have any expression at the end of the file, it's nearly impossible to get this done right.
If you could please prepare some examples with the expected behaviour it would be much easier to at least check if this is achievable.

@rhdunn
Copy link
Author

rhdunn commented Jun 25, 2016

The immediate case is related to issue #198:

declare function a($x, $y) {
    if ($x < (2*$y)) then
        $y
    else
        $x
};

declare function b($x) {
    ()
};

Here, the code in the $x and $y part of the if will not be validated, and function b will not be exposed to the user when referring to it in another module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants