-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2057 from usethesource/recovery/only-recovery-sta…
…cks-left Trigger recovery when only recovery stacks are left
- Loading branch information
Showing
15 changed files
with
186 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ dependency-reduced-pom.xml | |
|
||
*.iml | ||
.idea/ | ||
|
||
# generated by error recovery benchmark | ||
rascal-recovery-stats.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/InfiniteLoopMultiError.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module lang::rascal::tests::concrete::recovery::bugs::InfiniteLoopMultiError | ||
|
||
|
||
import lang::rascal::tests::concrete::recovery::RecoveryTestSupport; | ||
import lang::rascal::\syntax::Rascal; | ||
import ParseTree; | ||
import IO; | ||
|
||
void testInfiniteLoopMultiError() { | ||
standardParser = parser(#start[Module], allowRecovery=false, allowAmbiguity=true); | ||
recoveryParser = parser(#start[Module], allowRecovery=true, allowAmbiguity=true); | ||
source = |std:///Exception.rsc|; | ||
input = readFile(source); | ||
testDeleteUntilEol(standardParser, recoveryParser, source, input, 200, 100, begin=662, end=664); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/MinimalMultiError.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module lang::rascal::tests::concrete::recovery::bugs::MinimalMultiError | ||
|
||
import lang::rascal::tests::concrete::recovery::RecoveryTestSupport; | ||
|
||
layout Layout = [\ ]* !>> [\ ]; | ||
|
||
syntax S = T; | ||
|
||
syntax T = AB AB AB End; | ||
syntax AB = 'a' 'b'; | ||
syntax End = "$"; | ||
|
||
test bool multiOk() = checkRecovery(#S, "ababab$", []); | ||
|
||
test bool multiOneError() = checkRecovery(#S, "acabab$", ["c"]); | ||
|
||
test bool multiTwoError() = checkRecovery(#S, "acacab$", ["c","c"]); |
51 changes: 51 additions & 0 deletions
51
src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/MultiErrorBug.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module lang::rascal::tests::concrete::recovery::bugs::MultiErrorBug | ||
|
||
import ParseTree; | ||
import IO; | ||
import util::ErrorRecovery; | ||
import List; | ||
import vis::Text; | ||
|
||
start syntax Module = SyntaxDefinition* ; | ||
|
||
syntax SyntaxDefinition = Prod ";" ; | ||
|
||
lexical Name = [A-Z]; | ||
|
||
syntax Sym | ||
= Sym NonterminalLabel | ||
| StringConstant | ||
; | ||
|
||
lexical StringConstant = "\"" StringCharacter* "\"" ; | ||
|
||
lexical StringCharacter = ![\"] ; | ||
|
||
lexical NonterminalLabel = [a-z] ; | ||
|
||
syntax Prod = Sym* ; | ||
|
||
// This is an open issue: instead of two small errors, one big error tree is returned. | ||
bool multiErrorBug() { | ||
str input = "#\"a\";#\"b\";"; | ||
Tree t = parser(#start[Module], allowRecovery=true, allowAmbiguity=true)(input, |unknown:///?visualize=false|); | ||
|
||
println(prettyTree(t)); | ||
|
||
list[Tree] errors = findAllErrors(t); | ||
println("<size(errors)> Errors"); | ||
for (Tree error <- errors) { | ||
Tree skipped = getSkipped(error); | ||
println(" <skipped@\loc>: <getErrorText(error)>"); | ||
} | ||
Tree disambiguated = disambiguateErrors(t); | ||
list[Tree] disambiguatedErrors = findAllErrors(disambiguated); | ||
println("After disambiguating:"); | ||
println("<size(disambiguatedErrors)> Errors"); | ||
for (Tree error <- disambiguatedErrors) { | ||
Tree skipped = getSkipped(error); | ||
println(" <skipped@\loc>: <getErrorText(error)>"); | ||
} | ||
return true; | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/MultiErrorPico.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module lang::rascal::tests::concrete::recovery::bugs::MultiErrorPico | ||
|
||
import lang::pico::\syntax::Main; | ||
import lang::rascal::tests::concrete::recovery::RecoveryTestSupport; | ||
|
||
bool multiErrorPico() { | ||
return checkRecovery(#start[Program], "begin | ||
declare; | ||
i := #1; | ||
j := #2; | ||
k := 3 | ||
end" , ["#1", "#2"]); | ||
} |
6 changes: 6 additions & 0 deletions
6
src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/MultiErrorPicoInput.pico
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
begin | ||
declare; | ||
i := #1; | ||
j := #2; | ||
k := 3 | ||
end |
20 changes: 20 additions & 0 deletions
20
src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/MultiProdRecovery.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module lang::rascal::tests::concrete::recovery::bugs::MultiProdRecovery | ||
|
||
import lang::rascal::tests::concrete::recovery::RecoveryTestSupport; | ||
|
||
layout Layout = [\ ]* !>> [\ ]; | ||
|
||
syntax Prog = Stat*; | ||
|
||
syntax Stat | ||
= Expr ";" | ||
| "{" Stat* "}"; | ||
|
||
syntax Expr | ||
= Expr "+" Expr | ||
| Expr "-" Expr | ||
| "e"; | ||
|
||
test bool multiProdOk() = checkRecovery(#Prog, "{ e + e; }", []); | ||
|
||
test bool multiProdOperatorError() = checkRecovery(#Prog, "{ e * e; }", ["* "]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters