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

added a function that can filter error trees which are in optional positions in a grammar (list elements and optionals) #2074

Open
wants to merge 6 commits into
base: feat/error-recovery
Choose a base branch
from

Conversation

jurgenvinju
Copy link
Member

@jurgenvinju jurgenvinju commented Nov 8, 2024

This could be one of those library functions in Recovery.rsc that is useful to call from a language service. It uses information from grammar rules (so "language-parametric") to decide that the error tree can be ignored in principle.

  • list elements that are erroneous are simply removed while the other elements remain, including surrounding separators.
  • optional elements which happen to be errors are simply removed.

have to add tests for this of course, before we merge.

…sitions in a grammar (list elements and optionals)
@jurgenvinju jurgenvinju self-assigned this Nov 8, 2024
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49%. Comparing base (415773f) to head (2725c65).

Additional details and impacted files
@@                  Coverage Diff                  @@
##             feat/error-recovery   #2074   +/-   ##
=====================================================
  Coverage                     49%     49%           
  Complexity                  6605    6605           
=====================================================
  Files                        685     685           
  Lines                      61148   61148           
  Branches                    8850    8850           
=====================================================
+ Hits                       30239   30243    +4     
+ Misses                     28706   28702    -4     
  Partials                    2203    2203           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

data Tree(int skipped = 0, bool erroneous=false);

@synopsis{Annotates all nodes of a parse tree with error recovery statistics}
@description{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is helpful, but disambiguateErrors (implemented in Java) does something similar while disambiguating.
Maybe we can merge the two.

Note that the method you implemented here will bring down the system when a highly ambiguous error tree (not uncommon) is supplied, because sharing will be lost.
I think adding @memo might solve this, but we might want to consider implementing this in Java by reusing some of the disambiguateErrors implementation.

Because of your implementation here I just realized disambiguateErrors currently has a bug because it considers error trees with an empty skipped part as a non-error trees. This has become a bug only after #2053 was merged. I will fix this issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. I added it here as an experiment/demo to see how we can write this kind of code in Rascal. I suspect most of this will be called from Rascal in the future. Good catch with the @memo! We don't have a visit strategy that incorporates memo, so that is really something to watch out for here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we merge this we should probably stick with the Java version for now, given that it is much fast in dangerous cases with lots of nested ambiguity.

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

Successfully merging this pull request may close these issues.

2 participants