Skip to content

Commit

Permalink
improved readability of private addStats function
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Nov 13, 2024
1 parent c447811 commit c32f3bd
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/org/rascalmpl/library/util/ErrorRecovery.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,26 @@ Tree addErrorStats(Tree x) = bottom-up visit(x) {
};

@synopsis{Reusable utility for re-computing error statistics per Tree node.}
private Tree addStats(t:appl(prod(_,_,_), args)) = t[skipped = (0 | it + a.skipped | a <- args)][erroneous = (false | it || a.erroneous | a <- args)];
private Tree addStats(t:appl(skipped(_), args)) = t[skipped = size(args)][erroneous = true];
private Tree addStats(t:appl(error(_,_,_), args))= t[skipped = (0 | it + a.skipped | a <- args)][erroneous = true];
private Tree addStats(t:amb(alts)) = t[skipped = (0 | min([it, a.skipped]) | a <- alts)][erroneous = (false | it && a.erroneous | a <- alts)];
private Tree addStats(t:appl(prod(_,_,_), args))
= t
[skipped = (0 | it + a.skipped | a <- args)]
[erroneous = (false | it || a.erroneous | a <- args)];

private Tree addStats(t:appl(skipped(_), args))
= t
[skipped = size(args)]
[erroneous = true];

private Tree addStats(t:appl(error(_,_,_), args))
= t
[skipped = (0 | it + a.skipped | a <- args)]
[erroneous = true];

private Tree addStats(t:amb(alts))
= t
[skipped = (0 | min([it, a.skipped]) | a <- alts)]
[erroneous = (false | it && a.erroneous | a <- alts)];

default private Tree addStats(Tree t) = t;

@synopsis{Disambiguates error ambiguity clusters by selecting the alternatives with the shortest amount of skipped characters}
Expand Down

0 comments on commit c32f3bd

Please sign in to comment.