From 4fcc1d114b03b9b5fb4ebeb6edd1e98c4cb3efcd Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 09:49:55 +0200 Subject: [PATCH 01/13] borrowed upgrade folder from no-more-annotations branch to reuse refactoring code --- .../UpdateNestedListAndSetPatterns.rsc | 20 +------ .../UpgradeAnnotationsToKeywordParameters.rsc | 55 +++++++++++++++++++ .../lang/rascal/upgrade/UpgradeBase.rsc | 33 +++++++++++ .../UpgradePostfixStarAndPlusToPrefix.rsc | 28 +++------- 4 files changed, 99 insertions(+), 37 deletions(-) create mode 100644 src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc create mode 100644 src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpdateNestedListAndSetPatterns.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpdateNestedListAndSetPatterns.rsc index c1d6de2f449..8e1da83ba8f 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpdateNestedListAndSetPatterns.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpdateNestedListAndSetPatterns.rsc @@ -1,26 +1,12 @@ @bootstrapParser module lang::rascal::upgrade::UpdateNestedListAndSetPatterns -import lang::rascal::\syntax::Rascal; -import util::FileSystem; -import ParseTree; -import IO; -import Message; - -list[Message] report(loc root) - = [*report(parse(#start[Module], m)) | m <- find(root, "rsc")]; - -void update(loc root) { - modules = [ f | /file(f) := crawl(root), f.extension == "rsc"]; - for (m <- modules) { - writeFile(m, ""); - } -} +extend lang::rascal::upgrade::UpgradeBase; list[Message] report(Tree m) - = [info("found postfix multivar", name@\loc) | /(Pattern) `*` := m]; + = [info("found postfix multivar", name.origin) | /(Pattern) `*` := m]; -Tree updateTree(Tree m) = +Tree update(Tree m) = visit(m) { case (Pattern) `*` => (Pattern) `*` }; diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc new file mode 100644 index 00000000000..35a933aef31 --- /dev/null +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc @@ -0,0 +1,55 @@ +@bootstrapParser +module lang::rascal::upgrade::UpgradeAnnotationsToKeywordParameters + +extend lang::rascal::upgrade::UpgradeBase; + +anno loc Tree@\loc; + +list[Message] report(Tree m) + = [info("found annotation definition", name@\loc) | /(Declaration) ` anno @;` := m] + + [info("found annotation use", name@\loc) | /(Expression) `@` := m] + + [info("found annotion literal", name@\loc) | /(Expression) `[@=]` := m] + + [info("found annotation update", field@\loc) | /(Assignable) `@` := m] + ; + +Tree update(Tree m) = + top-down visit(m) { + case (Declaration) ` anno @;` + => (Declaration) ` + 'data ( = );` + when Expression init := getInitializer(t), Name name2 := getName(name) + + case (Expression) `@ ? ` => (Expression) `.` + when Name name2 := getName(name) + + case (Expression) `@` => (Expression) `.` + when Name name2 := getName(name) + + case (Expression) `[@=]` => (Expression) `[=]` + when Name name2 := getName(name) + + case (Expression) `delAnnotations()` => (Expression) `unset()` + + case (Assignable) `@` => (Assignable) `.` + when Name name2 := getName(field) + }; + +Name getName((Name) `\\loc`) = (Name) `origin`; +Name getName((Name) `src`) = (Name) `origin`; +Name getName((Name) `location`) = (Name) `origin`; +default Name getName(Name n) = n; + +test bool nameTest() = getName((Name) `location`) == (Name) `origin`; + +Expression getInitializer((Type) `rel[<{TypeArg ","}* elem>]`) = (Expression) `{}`; +Expression getInitializer((Type) `list[]`) = (Expression) `[]`; +Expression getInitializer((Type) `map[,]`) = (Expression) `()`; +Expression getInitializer((Type) `set[]`) = (Expression) `{}`; +Expression getInitializer((Type) `real`) = (Expression) `0.0`; +Expression getInitializer((Type) `int`) = (Expression) `0`; +Expression getInitializer((Type) `num`) = (Expression) `0`; +Expression getInitializer((Type) `str`) = (Expression) `""`; +Expression getInitializer((Type) `value`) = (Expression) `[]`; +Expression getInitializer((Type) `rat`) = (Expression) `r0`; +Expression getInitializer((Type) `loc`) = (Expression) `|unknown:///|`; +default Expression getInitializer(Type t) = (Expression) ` () { throw "no default value"; }()`; \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc new file mode 100644 index 00000000000..42d986854cc --- /dev/null +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc @@ -0,0 +1,33 @@ +@bootstrapParser +module lang::rascal::upgrade::UpgradeBase + +import lang::rascal::\syntax::Rascal; +import util::FileSystem; +import ParseTree; +import IO; +import Message; +import Exception; + +list[Message] report(loc root) + = [*reportFor(m) | m <- find(root, "rsc")]; + +list[Message] reportFor(loc l) { + try { + return report(parse(#start[Module], l)); + } catch ParseError(loc r) : + return [warning("parse error in Rascal file",r)]; +} + +void update(loc root) { + modules = [ f | /file(f) := crawl(root), f.extension == "rsc"]; + for (m <- modules) { + try + writeFile(m, ""); + catch ParseError(l): + println("parse error in , skipped"); + } +} + +default list[Message] report(Tree m) = []; +default Tree update(Tree m) = m; + diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradePostfixStarAndPlusToPrefix.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradePostfixStarAndPlusToPrefix.rsc index 22b9f2c8790..5f01f5d376e 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradePostfixStarAndPlusToPrefix.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradePostfixStarAndPlusToPrefix.rsc @@ -1,38 +1,26 @@ @bootstrapParser module lang::rascal::upgrade::UpgradePostfixStarAndPlusToPrefix -import util::FileSystem; -import lang::rascal::\syntax::Rascal; -import ParseTree; -import IO; -import Message; - -list[Message] report(loc root) - = [*report(parse(#start[Module], m)) | m <- find(root, "rsc")]; - -void update(loc root) { - for (m <- find(root, "rsc")) { - writeFile(m, ""); - } -} +import lang::rascal::upgrade::UpgradeBase; list[Message] report(Tree m) { result = []; visit(m) { - case (Pattern) `[<{Pattern ","}* _>,list[] ,<{Pattern ","}* _>]` : - result += [info("found list pattern to upgrade", elem@\loc)]; - case (Pattern) `{<{Pattern ","}* _>,set[] ,<{Pattern ","}* _>}` : - result += [info("found list pattern to upgrade", elem@\loc)]; + case (Pattern) `[<{Pattern ","}* before>,list[] ,<{Pattern ","}* after>]` : + result += [info("found list pattern to upgrade", elem.origin)]; + case (Pattern) `{<{Pattern ","}* before>,set[] ,<{Pattern ","}* after>}` : + result += [info("found list pattern to upgrade", elem.origin)]; + case Pattern p : ; } return result; } -public Tree updateTree(Tree m) = +public Tree update(Tree m) = innermost visit(m) { case (Pattern) `[<{Pattern ","}* before>,list[] ,<{Pattern ","}* after>]` => (Pattern) `[<{Pattern ","}* before>, * , <{Pattern ","}* after>]` case (Pattern) `{<{Pattern ","}* before>,set[] ,<{Pattern ","}* after>}` => (Pattern) `{<{Pattern ","}* before>, * , <{Pattern ","}* after>}` - case Pattern _ : fail; + case Pattern p : fail; }; From f07a9b0699c145220e6ed7c1135a6e71d3b950eb Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 09:59:41 +0200 Subject: [PATCH 02/13] ran update function on Assignment test module --- .../rascal/tests/functionality/Assignment.rsc | 20 ++++++++++--------- .../UpgradeAnnotationsToKeywordParameters.rsc | 8 ++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Assignment.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Assignment.rsc index ef9a641ab5c..129ad342c1a 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Assignment.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Assignment.rsc @@ -1,3 +1,4 @@ + module lang::rascal::tests::functionality::Assignment import Exception; @@ -95,23 +96,24 @@ test bool testADT33() { D d = intfield(5); d.i *= 3; return d == intfield(15); } test bool testADT34() { D d = intfield(6); d.i /= 3; return d == intfield(2); } data F = f() | f(int n) | g(int n) | deep(F f); -anno int F@pos; + +data F(int pos = 0); -// testAnnotations +// testAnnotations (the annotation syntax has been replaced by keywordparameters but we have kept the tests for reference.) -test bool testAnnotations1() { F X = f(); X@pos = 1; return X@pos == 1; } +test bool testAnnotations1() { F X = f(); X.pos = 1; return X.pos == 1; } -test bool testAnnotations2() { X = f(); X@pos = 2; X@pos += 3; return X@pos == 5; } +test bool testAnnotations2() { X = f(); X.pos = 2; X.pos += 3; return X.pos == 5; } -test bool testAnnotations3() { X = f(); X@pos = 3; X@pos -= 2; return X@pos == 1; } +test bool testAnnotations3() { X = f(); X.pos = 3; X.pos -= 2; return X.pos == 1; } -test bool testAnnotations4() { X = f(); X@pos = 2; X@pos *= 3; return X@pos == 6; } +test bool testAnnotations4() { X = f(); X.pos = 2; X.pos *= 3; return X.pos == 6; } -test bool testAnnotations5() { X = f(); X@pos = 6; X@pos /= 3; return X@pos == 2; } +test bool testAnnotations5() { X = f(); X.pos = 6; X.pos /= 3; return X.pos == 2; } -test bool testAnnotations6() { X = f(); X@pos = 6; X@pos ?= 3; return X@pos == 6; } +test bool testAnnotations6() { X = f(); X.pos = 6; X.pos ?= 3; return X.pos == 6; } -test bool testAnnotations7() { X = f(); X@pos ?= 3; return X@pos == 3; } +test bool testAnnotations7() { X = f(); X.pos ?= 3; return X.pos == 3; } // assigningClosureToVariableBug877 diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc index 35a933aef31..60c258340d5 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc @@ -34,12 +34,12 @@ Tree update(Tree m) = when Name name2 := getName(field) }; -Name getName((Name) `\\loc`) = (Name) `origin`; -Name getName((Name) `src`) = (Name) `origin`; -Name getName((Name) `location`) = (Name) `origin`; +Name getName((Name) `\\loc`) = (Name) `src`; +Name getName((Name) `src`) = (Name) `src`; +Name getName((Name) `location`) = (Name) `src`; default Name getName(Name n) = n; -test bool nameTest() = getName((Name) `location`) == (Name) `origin`; +test bool nameTest() = getName((Name) `location`) == (Name) `src`; Expression getInitializer((Type) `rel[<{TypeArg ","}* elem>]`) = (Expression) `{}`; Expression getInitializer((Type) `list[]`) = (Expression) `[]`; From 498719a81c40e64001b68641b6817b822cb19842 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 10:01:30 +0200 Subject: [PATCH 03/13] rewrote the annotation tests using the update refactoring --- .../rascal/tests/functionality/Annotation.rsc | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc index ef5934d502a..6727d3c0eed 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc @@ -7,30 +7,33 @@ } @contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI} @contributor{Paul Klint - Paul.Klint@cwi.nl - CWI} +@synopsis{The old annotation feature has been replaced by the keyword field feature, but we kept the tests for reference.} module lang::rascal::tests::functionality::Annotation import Exception; data F = f() | f(int n) | g(int n) | deep(F f); -anno int F@pos; + +data F(int pos = 0); data AN = an(int n); -anno int F@notThere; + +data F(int notThere = 0); // boolannotations -test bool boolannotations1() = true || /*documentation of old behavior: */ f() [@pos=1] == f(); -test bool boolannotations2() = f() [@pos=1]@pos == 1; -test bool boolannotations3() = f() [@pos=1][@pos=2]@pos == 2; +test bool boolannotations1() = true || /*documentation of old behavior: */ f()[pos=1] == f(); +test bool boolannotations2() = f()[pos=1].pos == 1; +test bool boolannotations3() = f()[pos=1][pos=2].pos == 2; // since annotations are simulated by kw params this is no longer true: -test bool boolannotations4() = true || /*documentation of old behavior: */ f(5) [@pos=1] == f(5); -test bool boolannotations5() = true || /*documentation of old behavior: */ f(5) [@pos=1]@pos == 1; -test bool boolannotations6() = true || /*documentation of old behavior: */ f(5) [@pos=1][@pos=2]@pos == 2; +test bool boolannotations4() = true || /*documentation of old behavior: */ f(5)[pos=1] == f(5); +test bool boolannotations5() = true || /*documentation of old behavior: */ f(5)[pos=1].pos == 1; +test bool boolannotations6() = true || /*documentation of old behavior: */ f(5)[pos=1][pos=2].pos == 2; // since annotations are simulated by kw params this is no longer true -test bool boolannotations7() = true || /*documentation of old behavior: */ deep(f(5) [@pos=1]) == deep(f(5)); -test bool boolannotations8() = true || /*documentation of old behavior: */ f(5) [@pos=1] == f(5) [@pos=2]; +test bool boolannotations7() = true || /*documentation of old behavior: */ deep(f(5)[pos=1]) == deep(f(5)); +test bool boolannotations8() = true || /*documentation of old behavior: */ f(5)[pos=1] == f(5)[pos=2]; // annotationsInSets // since annotations are simulated by kw params this is no longer true: @@ -44,21 +47,21 @@ test bool boolannotations8() = true || /*documentation of old behavior: */ f(5) @ignoreCompiler{Annotations are not supported as keyword field} test bool accessAnnoAsKeywordField(){ F example = f(); - example@pos = 1; + example.pos = 1; return example.pos == 1; } @ignoreCompiler{Annotations are not supported as keyword field} test bool accessAnnoUpdateAsKeywordField(){ F example = f(); - example@pos = 1; - return example[@pos=2].pos == 2; + example.pos = 1; + return example[pos=2].pos == 2; } @ignoreCompiler{Annotations are not supported as keyword field} test bool checkAnnoExistsAsKeywordField(){ F example = f(); - example@pos = 1; + example.pos = 1; return example.pos?; } @@ -67,29 +70,29 @@ test bool checkAnnoExistsAsKeywordField(){ test bool KeywordFieldUpdateVisibleAsAnno(){ F example = f(); // keyword updates are visible to anno projection - return example[pos=3]@\pos == 3; + return example[pos=3].\pos == 3; } @ignoreCompiler{Annotations are not supported as keyword field} test bool KeywordAssignVisibleViaAnno1(){ F example = f(); - example@pos = 1; + example.pos = 1; example.pos = 4; - return example@pos == 4; + return example.pos == 4; } @ignoreCompiler{Annotations are not supported as keyword field} test bool KeywordAssignVisibleViaAnno2(){ F example = f(); - example@pos = 1; + example.pos = 1; example.pos += 4; - return example@pos == 5; + return example.pos == 5; } test bool unavailableAnno1(){ F example = f(); try { - example@notThere; + example.notThere; return false; } catch NoSuchAnnotation("notThere"): From 20431c8c987f3633625b0e71f77c7e10e5c7cbed Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 10:05:44 +0200 Subject: [PATCH 04/13] automatically refactored all declarations and uses of annotations --- src/org/rascalmpl/library/ParseTree.rsc | 34 +++---- .../library/analysis/grammars/Ambiguity.rsc | 78 +++++++-------- .../library/analysis/text/search/Grammars.rsc | 6 +- .../rascal/grammar/definition/Productions.rsc | 2 +- .../grammar/storage/ModuleParserStorage.rsc | 2 +- .../library/lang/rascal/ide/Outline.rsc | 62 ++++++------ .../library/lang/rascal/scrap/Patch.rsc | 8 +- .../lang/rascal/tests/basic/Booleans.rsc | 7 +- .../lang/rascal/tests/basic/Functions.rsc | 2 +- .../lang/rascal/tests/basic/IsDefined.rsc | 33 ++++--- .../library/lang/rascal/tests/basic/Sets.rsc | 3 +- .../lang/rascal/tests/concrete/Locations.rsc | 22 ++--- .../lang/rascal/tests/concrete/Patterns3.rsc | 98 +++---------------- .../lang/rascal/tests/concrete/Syntax5.rsc | 2 +- .../rascal/tests/functionality/Visit1.rsc | 21 ++-- .../rascal/tests/functionality/Visit2.rsc | 39 +++----- .../lang/rascal/tests/library/Node.rsc | 64 ++++++------ .../UpgradeAnnotationsToKeywordParameters.rsc | 11 ++- .../lang/sdf2/filters/DetectCycles.rsc | 2 +- src/org/rascalmpl/library/vis/Basic.rsc | 2 +- src/org/rascalmpl/library/vis/Text.rsc | 2 +- 21 files changed, 212 insertions(+), 288 deletions(-) diff --git a/src/org/rascalmpl/library/ParseTree.rsc b/src/org/rascalmpl/library/ParseTree.rsc index 3289f88fd2c..ab05f26df22 100644 --- a/src/org/rascalmpl/library/ParseTree.rsc +++ b/src/org/rascalmpl/library/ParseTree.rsc @@ -329,8 +329,8 @@ Production associativity(Symbol s, Associativity as, {*Production a, priority(Sy = associativity(s, as, {*a, *b}); -@synopsis{Annotate a parse tree node with a source location.} -anno loc Tree@\loc; +@synopsis{Annotate a parse tree node with a source location.} +data Tree(loc src = |unknown:///|); @synopsis{Parse input text (from a string or a location) and return a parse tree.} @@ -692,35 +692,35 @@ data Exp = add(Exp, Exp); java &T<:value implode(type[&T<:value] t, Tree tree); -@synopsis{Annotate a parse tree node with an (error) message.} -anno Message Tree@message; +@synopsis{Annotate a parse tree node with an (error) message.} +data Tree(Message message = Message () { throw "no default value"; }()); -@synopsis{Annotate a parse tree node with a list of (error) messages.} -anno set[Message] Tree@messages; +@synopsis{Annotate a parse tree node with a list of (error) messages.} +data Tree(set[Message] messages = {}); -@synopsis{Annotate a parse tree node with a documentation string.} -anno str Tree@doc; +@synopsis{Annotate a parse tree node with a documentation string.} +data Tree(str doc = ""); -@synopsis{Annotate a parse tree node with documentation strings for several locations.} -anno map[loc,str] Tree@docs; +@synopsis{Annotate a parse tree node with documentation strings for several locations.} +data Tree(map[loc,str] docs = ()); -@synopsis{Annotate a parse tree node with the target of a reference.} -anno loc Tree@link; +@synopsis{Annotate a parse tree node with the target of a reference.} +data Tree(loc link = |unknown:///|); -@synopsis{Annotate a parse tree node with multiple targets for a reference.} -anno set[loc] Tree@links; +@synopsis{Annotate a parse tree node with multiple targets for a reference.} +data Tree(set[loc] links = {}); @synopsis{Annotate the top of the tree with hyperlinks between entities in the tree (or other trees) -This is similar to link and links annotations, except that you can put it as one set at the top of the tree.} -anno rel[loc,loc] Tree@hyperlinks; +This is similar to link and links annotations, except that you can put it as one set at the top of the tree.} +data Tree(rel[loc,loc] hyperlinks = {}); @synopsis{Tree search result type for ((treeAt)).} @@ -733,7 +733,7 @@ data TreeSearchResult[&T<:Tree] = treeFound(&T tree) | treeNotFound(); } TreeSearchResult[&T<:Tree] treeAt(type[&T<:Tree] t, loc l, Tree a:appl(_, _)) { - if ((a@\loc)?, al := a@\loc, al.offset <= l.offset, al.offset + al.length >= l.offset + l.length) { + if ((a.src)?, al := a.src, al.offset <= l.offset, al.offset + al.length >= l.offset + l.length) { for (arg <- a.args, TreeSearchResult[&T<:Tree] r:treeFound(&T<:Tree _) := treeAt(t, l, arg)) { return r; } diff --git a/src/org/rascalmpl/library/analysis/grammars/Ambiguity.rsc b/src/org/rascalmpl/library/analysis/grammars/Ambiguity.rsc index 5cd62227a41..3b68f794fec 100644 --- a/src/org/rascalmpl/library/analysis/grammars/Ambiguity.rsc +++ b/src/org/rascalmpl/library/analysis/grammars/Ambiguity.rsc @@ -26,7 +26,7 @@ public list[Message] diagnose(str amb) { } public list[Message] findCauses(Tree a) { - return [info("Ambiguity cluster with alternatives", a@\loc?|dunno:///|)] + return [info("Ambiguity cluster with alternatives", a.src)] + [*findCauses(x, y) | [*_,Tree x,*_,Tree y, *_] := toList(a.alternatives), true /* workaround alert*/]; } @@ -36,22 +36,22 @@ public list[Message] findCauses(Tree x, Tree y) { list[Message] result = []; if (pX == pY) { - result += [info("The alternatives use the same productions", x@\loc?|dunno:///|)]; + result += [info("The alternatives use the same productions", x.src)]; } else { - result += [info("Production unique to the one alternative: ;", x@\loc?|dunno:///|) | p <- pX - pY]; - result += [info("Production unique to the other alternative: ;", x@\loc?|dunno:///|) | p <- pY - pX]; + result += [info("Production unique to the one alternative: ;", x.src) | p <- pX - pY]; + result += [info("Production unique to the other alternative: ;", x.src) | p <- pY - pX]; } if (appl(prodX,_) := x, appl(prodY,_) := y) { if (prodX == prodY) { - result += [info("The alternatives have the same production at the top: ", x@\loc?|dunno:///|)]; + result += [info("The alternatives have the same production at the top: ", x.src)]; } else { result += [info("The alternatives have different productions at the top, one has ' 'while the other has - ' ", x@\loc?|dunno:///|)]; + ' ", x.src)]; } } @@ -78,7 +78,7 @@ public list[Message] exceptAdvise(Tree x, set[Production] _, set[Production] pY) } else { result += [warning("You should give this production a good label: - ' ]",x@\loc?|dunno:///|)]; + ' ]",x.src)]; } result += [error("To fix this issue, you could restrict the nesting of @@ -86,7 +86,7 @@ public list[Message] exceptAdvise(Tree x, set[Production] _, set[Production] pY) 'under ' 'using the ! operator on argument : ! - 'However, you should realize that you are introducing a restriction that makes the language smaller",x@\loc?|dunno:///|)]; + 'However, you should realize that you are introducing a restriction that makes the language smaller",x.src)]; } } @@ -108,22 +108,22 @@ public list[Message] deeperCauses(Tree x, Tree y, set[Production] pX, set[Produc result = []; if (rX<0> != rY<0> || lX<1> != lY<1>) { - result += [info("The alternatives have different lexicals/literals/layout", x@\loc?|dunno:///| )]; - result += [info("Unique lexical to the one: ;", t[0]@\loc?|dunno:///|) | t <- (rX - rY), p := t[0].prod]; - result += [info("Unique lexical to the other: ;", t[0]@\loc?|dunno:///|) | t <- (rY - rX), p := t[0].prod]; - result += [info("Unique literal to the one: ", x@\loc?|dunno:///|) | t <- lX - lY]; - result += [info("Unique literal to the other: ", x@\loc?|dunno:///|) | t <- lY - lX]; - result += [info("Unique layout to the one: ", x@\loc?|dunno:///|) | t <- laX - laY]; - result += [info("Unique layout to the other: ", x@\loc?|dunno:///|) | t <- laY - laX]; + result += [info("The alternatives have different lexicals/literals/layout", x.src )]; + result += [info("Unique lexical to the one: ;", t[0].src) | t <- (rX - rY), p := t[0].prod]; + result += [info("Unique lexical to the other: ;", t[0].src) | t <- (rY - rX), p := t[0].prod]; + result += [info("Unique literal to the one: ", x.src) | t <- lX - lY]; + result += [info("Unique literal to the other: ", x.src) | t <- lY - lX]; + result += [info("Unique layout to the one: ", x.src) | t <- laX - laY]; + result += [info("Unique layout to the other: ", x.src) | t <- laY - laX]; // literals that became lexicals and vice versa - result += [error("You might reserve from , i.e. using a reject (reserved keyword).", r@\loc?|dunno:///|) | <- rX o lY]; - result += [error("You might reserve from , i.e. using a reject (reserved keyword).", r@\loc?|dunno:///|) | <- rY o lX]; + result += [error("You might reserve from , i.e. using a reject (reserved keyword).", r.src) | <- rX o lY]; + result += [error("You might reserve from , i.e. using a reject (reserved keyword).", r.src) | <- rY o lX]; // lexicals that overlap position, but are shorter (longest match issue) for ( <- rX, <- rY, tX != tY) { - tXl = tX@\loc; - tYl = tY@\loc; + tXl = tX.src; + tYl = tY.src; // <--------> // <---> @@ -153,14 +153,14 @@ public list[Message] deeperCauses(Tree x, Tree y, set[Production] pX, set[Produc // find parents of literals, and transfer location - polX = { | /t:appl(p,[*_,l:appl(prod(lit(_),_,_),_),*_]) := x, true}; - polY = { | /t:appl(p,[*_,l:appl(prod(lit(_),_,_),_),*_]) := y, true}; + polX = { | /t:appl(p,[*_,l:appl(prod(lit(_),_,_),_),*_]) := x, true}; + polY = { | /t:appl(p,[*_,l:appl(prod(lit(_),_,_),_),*_]) := y, true}; overloadedLits = [info("Literal \"\" is used in both ' and - ' ", l@\loc) | <- polX, <- polY, p != q, !(p in pY || q in pX)]; + ' ", l.src) | <- polX, <- polY, p != q, !(p in pY || q in pX)]; if (overloadedLits != []) { - result += info("Re-use of these literals is causing different interpretations of the same source.", x@\loc?|dunno:///|); + result += info("Re-use of these literals is causing different interpretations of the same source.", x.src); result += overloadedLits; fatherChildX = { | appl(p, [*a,appl(q,_),*_]) := x, q.def is sort || q.def is lex, true}; @@ -172,14 +172,14 @@ public list[Message] deeperCauses(Tree x, Tree y, set[Production] pX, set[Produc labelApX = l; } else { - result += [warning("You should give this production a good label []",x@\loc?|dunno:///|)]; + result += [warning("You should give this production a good label []",x.src)]; } result += [error("You could safely restrict the nesting of ' 'under ' - 'using the ! operator on argument : !",x@\loc?|dunno:///|)]; + 'using the ! operator on argument : !",x.src)]; } } @@ -210,16 +210,16 @@ public list[Message] reorderingCauses(Tree x, Tree y) { list[Message] priorityCauses(Tree x, Tree y) { if (/appl(p,[appl(q,_),*_]) := x, /Tree t:appl(q,[*_,appl(p,_)]) := y, p != q) { return [error("You might add this priority rule (or vice versa): - ' ", t@\loc) + ' ", t.src) ,error("You might add this associativity rule (or right/assoc/non-assoc): - ' ", t@\loc?|dunno:///|)]; + ' ", t.src)]; } if (/appl(p,[appl(q,_),*_]) := y, /Tree t:appl(q,[*_,appl(p,_)]) := x, p != q) { return [error("You might add this priority rule (or vice versa): - ' ", t@\loc) + ' ", t.src) ,error("You might add this associativity rule (or right/assoc/non-assoc): - ' ", t@\loc?|dunno:///|)]; + ' ", t.src)]; } return []; @@ -237,12 +237,12 @@ list[Message] danglingCauses(Tree x, Tree y) { list[Message] danglingFollowSolutions(Tree x, Tree y) { if (prod(_, lhs, _) := x.prod, prod(_, [*pref, _, l:lit(_), *_], _) := y.prod, lhs == pref) { return [error("You might add a follow restriction for on: - ' ", x@\loc?|dunno:///|)]; + ' ", x.src)]; } if (prod(_, lhs, _) := y.prod, prod(_, [*pref, _, l:lit(_), *_], _) := x.prod, lhs == pref) { return [error("You might add a follow restriction for on: - ' ", x@\loc?|dunno:///|)]; + ' ", x.src)]; } return []; @@ -250,15 +250,15 @@ list[Message] danglingFollowSolutions(Tree x, Tree y) { list[Message] danglingOffsideSolutions(Tree x, Tree y) { if (appl(p,/Tree u:appl(q,_)) := x, appl(q,/appl(p,_)) := y - , (u@\loc).begin.column >= (x@\loc).begin.column - , (u@\loc).begin.line < (x@\loc).end.line) { - return [error("You might declare nested offside (to the left) of some child of using a failing syntax action that compares annotations @loc.start.column", u@\loc)]; + , (u.src).begin.column >= (x.src).begin.column + , (u.src).begin.line < (x.src).end.line) { + return [error("You might declare nested offside (to the left) of some child of using a failing syntax action that compares annotations @loc.start.column", u.src)]; } if (appl(p,/Tree u:appl(q,_)) := y, appl(q,/appl(p,_)) := x - , (u@\loc).begin.column >= (y@\loc).begin.column - , (u@\loc).begin.line < (y@\loc).end.line) { - return [error("You might declare nested offside (to the left) of some child of using a failing syntax action that compares annotations @loc.start.column", u@\loc)]; + , (u.src).begin.column >= (y.src).begin.column + , (u.src).begin.line < (y.src).end.line) { + return [error("You might declare nested offside (to the left) of some child of using a failing syntax action that compares annotations @loc.start.column", u.src)]; } return []; @@ -266,11 +266,11 @@ list[Message] danglingOffsideSolutions(Tree x, Tree y) { list[Message] associativityCauses(Tree x, Tree y) { if (/appl(p,[appl(p,_),*_]) := x, /Tree t:appl(p,[*_,appl(p,_)]) := y) { - return [error("This rule [] may be missing an associativity declaration (left, right, non-assoc)", t@\loc)]; + return [error("This rule [] may be missing an associativity declaration (left, right, non-assoc)", t.src)]; } if (/appl(p,[appl(p,_),*_]) := y, /Tree t:appl(p,[*_,appl(p,_)]) := x) { - return [error("This rule [] may be missing an associativity declaration (left, right, non-assoc)", t@\loc)]; + return [error("This rule [] may be missing an associativity declaration (left, right, non-assoc)", t.src)]; } return []; diff --git a/src/org/rascalmpl/library/analysis/text/search/Grammars.rsc b/src/org/rascalmpl/library/analysis/text/search/Grammars.rsc index 9262a23afa5..ddbb22a0c6a 100644 --- a/src/org/rascalmpl/library/analysis/text/search/Grammars.rsc +++ b/src/org/rascalmpl/library/analysis/text/search/Grammars.rsc @@ -14,7 +14,7 @@ Analyzer commentAnalyzerFromGrammar(type[&T <: Tree] grammar) = analyzer(comment Tokenizer tokenizerFromGrammar(type[&T <: Tree] grammar) = tokenizer(list[Term] (str input) { try { tr = parse(grammar, input, |lucene:///|, allowAmbiguity=true); - return [term("", token@\loc, "") | token <- tokens(tr, isToken) ]; + return [term("", token.src, "") | token <- tokens(tr, isToken) ]; } catch ParseError(_): return [term(input, |lucene:///|(0, size(input)), "entire input")]; @@ -24,7 +24,7 @@ Tokenizer tokenizerFromGrammar(type[&T <: Tree] grammar) = tokenizer(list[Term] Tokenizer identifierTokenizerFromGrammar(type[&T <: Tree] grammar) = tokenizer(list[Term] (str input) { try { tr = parse(grammar, input, |lucene:///|, allowAmbiguity=true); - return [term("", token@\loc, "") | token <- tokens(tr, isToken), isLexical(token)]; + return [term("", token.src, "") | token <- tokens(tr, isToken), isLexical(token)]; } catch ParseError(_): return [term(input, |lucene:///|(0, size(input)), "entire input")]; @@ -34,7 +34,7 @@ Tokenizer identifierTokenizerFromGrammar(type[&T <: Tree] grammar) = tokenizer(l Tokenizer commentTokenizerFromGrammar(type[&T <: Tree] grammar) = tokenizer(list[Term] (str input) { try { tr = parse(grammar, input, |lucene:///|, allowAmbiguity=true); - return [term("", comment@\loc, "") | comment <- tokens(tr, isComment)]; + return [term("", comment.src, "") | comment <- tokens(tr, isComment)]; } catch ParseError(_): return [term(input, |lucene:///|(0, size(input)), "entire input")]; diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc index 38d345354d4..8efaf8e4da1 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc @@ -53,7 +53,7 @@ public tuple[set[Production] prods, Maybe[Symbol] \start] rule2prod(SyntaxDefini return <{prod2prod(\lex(""), p)}, nothing()>; case \keyword(nonterminal(Nonterminal n), Prod p) : return <{prod2prod(keywords(""), p)}, nothing()>; - default: { iprintln(sd); throw "unsupported kind of syntax definition? at "; } + default: { iprintln(sd); throw "unsupported kind of syntax definition? at "; } } } diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/storage/ModuleParserStorage.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/storage/ModuleParserStorage.rsc index 06922856be8..bf9050a1851 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/storage/ModuleParserStorage.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/storage/ModuleParserStorage.rsc @@ -114,7 +114,7 @@ void storeParsersForModules(set[loc] moduleFiles, PathConfig pcfg) { void storeParsersForModules(set[Module] modules, PathConfig pcfg) { for (m <- modules) { - storeParserForModule("", m@\loc, modules, pcfg); + storeParserForModule("", m.src, modules, pcfg); } } diff --git a/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc b/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc index 65ee1b5e941..786c7a91d33 100644 --- a/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc +++ b/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc @@ -9,12 +9,18 @@ import String; anno str node@label; anno loc node@\loc; -anno loc FunctionDeclaration@\loc; -anno loc Declaration@\loc; -anno loc Name@\loc; -anno loc QualifiedName@\loc; -anno loc Signature@\loc; -anno loc Prod@\loc; + +data FunctionDeclaration(loc src = |unknown:///|); + +data Declaration(loc src = |unknown:///|); + +data Name(loc src = |unknown:///|); + +data QualifiedName(loc src = |unknown:///|); + +data Signature(loc src = |unknown:///|); + +data Prod(loc src = |unknown:///|); node outline(start[Module] m) = outline(m.top); @@ -33,20 +39,20 @@ node outline(Module m) { top-down-break visit (m) { case (Declaration) ` <{Variable ","}+ vars>;`: - variables += [clean(" ")()[@\loc=v@\loc] | v <- vars]; + variables += [clean(" ")()[src=v.src] | v <- vars]; case (Declaration) ` anno @;`: - annotations += [clean(" @")()[@\loc=name@\loc]]; + annotations += [clean(" @")()[src=name.src]]; case (Declaration) ` alias = ;`: - aliases += [clean("")()[@\loc=u.name@\loc]]; + aliases += [clean("")()[src=u.name.src]]; case (Declaration) ` tag on <{Type ","}+ _>;`: - tags += [clean("")()[@\loc=name@\loc]]; + tags += [clean("")()[src=name.src]]; case (Declaration) ` data ;`: { f = ""; c = adts[""]?e; if (kws is present) { - c += [ ". "()[@\loc=k@\loc] | KeywordFormal k <- kws.keywordFormalList]; + c += [ ". "()[src=k.src] | KeywordFormal k <- kws.keywordFormalList]; } adts[f] = c; @@ -57,16 +63,16 @@ node outline(Module m) { c = adts[f]?e; if (kws is present) { - c += [ ". "()[@\loc=k@\loc] | k <- kws.keywordFormalList]; + c += [ ". "()[src=k.src] | k <- kws.keywordFormalList]; } - c += [ clean("")()[@\loc=v@\loc] | v <- variants]; + c += [ clean("")()[src=v.src] | v <- variants]; adts[f] = c; } case FunctionDeclaration func : { - f = clean("")()[@label=" "][@\loc=func.signature@\loc]; + f = clean("")()[label=" "][src=func.signature.src]; if (/(FunctionModifier) `test` := func.signature) { tests[clean("")]?e += [f]; @@ -77,18 +83,18 @@ node outline(Module m) { } case (Import) `extend ;` : - imports += [""()[@\loc=mm@\loc]]; + imports += [""()[src=mm.src]]; case (Import) `import ;` : - imports += [""()[@\loc=mm@\loc]]; + imports += [""()[src=mm.src]]; case (Import) `import = ;` : - imports += [""()[@\loc=m2@\loc]]; + imports += [""()[src=m2.src]]; case SyntaxDefinition def : { f = ""; c = grammars[f]?e; - c += ["

"()[@label=""][@\loc=p@\loc] + c += ["

"()[label=""][src=p.src] | /Prod p := def.production, p is labeled || p is unlabeled, str prefix := (p is labeled ? ": " : "") ]; @@ -97,18 +103,18 @@ node outline(Module m) { } map[node,list[node]] count(map[str,list[node]] m) - = ((!isEmpty(m[k]) ? " ()"()[@\loc=(m[k][0])@\loc] : " ()"()) : m[k] | k <- m); + = ((!isEmpty(m[k]) ? " ()"()[src=(m[k][0]).src] : " ()"()) : m[k] | k <- m); return n( - "Functions"(count(functions))[@label="Functions ()"], - "Tests"(count(tests))[@label="Tests ()"], - "Variables"(variables)[@label="Variables ()"], - "Aliases"(aliases)[@label="Aliases ()"], - "Data"(count(adts))[@label="Data ()"], - "Annotations"(annotations)[@label="Annotations ()"], - "Tags"(tags)[@label="Tags ()"], - "Imports"(imports)[@label="Imports ()"], - "Syntax"(count(grammars))[@label="Syntax ()"] + "Functions"(count(functions))[label="Functions ()"], + "Tests"(count(tests))[label="Tests ()"], + "Variables"(variables)[label="Variables ()"], + "Aliases"(aliases)[label="Aliases ()"], + "Data"(count(adts))[label="Data ()"], + "Annotations"(annotations)[label="Annotations ()"], + "Tags"(tags)[label="Tags ()"], + "Imports"(imports)[label="Imports ()"], + "Syntax"(count(grammars))[label="Syntax ()"] ); } diff --git a/src/org/rascalmpl/library/lang/rascal/scrap/Patch.rsc b/src/org/rascalmpl/library/lang/rascal/scrap/Patch.rsc index 2d97d631e04..aa6b5421ce2 100644 --- a/src/org/rascalmpl/library/lang/rascal/scrap/Patch.rsc +++ b/src/org/rascalmpl/library/lang/rascal/scrap/Patch.rsc @@ -17,7 +17,7 @@ lrel[loc, str] commands2patch(start[Commands] pt) { // don't evaluate commands that represent output cmds = [ "" | c <- pt.top.commands, !(c is output) ]; - results = evalCommands(cmds, pt@\loc); + results = evalCommands(cmds, pt.src); patch = []; @@ -46,7 +46,7 @@ lrel[loc, str] commands2patch(start[Commands] pt) { // if there's a change in output, add a tuple // to the patch. if (new != "" && trim(old) != trim(new)) { - org = args[i]@\loc; + org = args[i].src; at = org.offset + org.length; l = org[offset=at][length=0]; // insert patch += []; @@ -60,7 +60,7 @@ lrel[loc, str] commands2patch(start[Commands] pt) { else { if (change) { // only remove previous output nodes if there was a change - patch += []; + patch += []; } // output commands are not evaluated by evalCommands above; @@ -73,7 +73,7 @@ lrel[loc, str] commands2patch(start[Commands] pt) { if (addedSpace && change && startsWith(l, " ")) { // if a leading space was added in the case of changed output, // remove it here. Otherwise leave the layout unchanged. - org = args[i]@\loc; + org = args[i].src; patch += []; addedSpace = false; } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/Booleans.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/Booleans.rsc index 709362202c8..d9729715513 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/Booleans.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/Booleans.rsc @@ -423,12 +423,13 @@ test bool compositeEquivBothBTCnt() { data AnotherAndData = a(); -anno list[int] AnotherAndData@l; + +data AnotherAndData(list[int] l = []); test bool anotherAnd() { - v = a()[@l = [1,2,3]]; + v = a()[l=[1,2,3]]; list[list[int]] res = []; - if(v@l? && [*int x,*int y] := v@l) { + if(v.l? && [*int x,*int y] := v.l) { res = res + [ x, y ]; fail; } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc index eff38a9960f..312772c56fb 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc @@ -8,7 +8,7 @@ data B = and(B lhs, B rhs) | or(B lhs, B rhs) | t() | f(); B and(B b1, and(B b2, B b3)) = and(and(b1,b2),b3); -value callDelAnnotations() = delAnnotations("f"(1,2,3)); +value callDelAnnotations() = unset("f"(1,2,3)); test bool testCallWithTypeParameterBound() = callDelAnnotations() == "f"(1,2,3); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc index 1f3aa5b83e4..4af37b03f5e 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc @@ -243,41 +243,42 @@ test bool tst() { int x = 10; y = x ? 1; return y == 10; } // Annotations data F = f3() | f3(int n) | g(int n) | deep(F f); -anno int F@pos; + +data F(int pos = 0); -test bool isDefinedAnno1() = (f3()[@pos=1])@pos?; +test bool isDefinedAnno1() = (f3()[pos=1]).pos?; -test bool isDefinedAnno2() = !(f3()@pos)?; +test bool isDefinedAnno2() = !(f3().pos)?; -test bool isDefinedAnno3() = ((f3()[@pos=1])@pos ? 10) == 1; +test bool isDefinedAnno3() = ((f3()[pos=1]).pos) == 1; -test bool isDefinedAnno4() = ((f3())@pos ? 10) == 10; +test bool isDefinedAnno4() = ((f3()).pos) == 10; test bool isDefinedAnno5(){ X = f3(); - X@pos ? 0 += 1; - return X@pos == 1; + X.pos ? 0 += 1; + return X.pos == 1; } test bool isDefinedAnno6(){ - X = f3()[@pos=1]; - X@pos ? 0 += 1; - return X@pos == 2; + X = f3()[pos=1]; + X.pos ? 0 += 1; + return X.pos == 2; } test bool isDefinedAnno7(){ X = f3(); - X@pos ?= 3; - return X@pos == 3; + X.pos ?= 3; + return X.pos == 3; } test bool isDefinedAnno8(){ - X = f3()[@pos = 1]; - X@pos ?= 3; - return X@pos == 1; + X = f3()[pos=1]; + X.pos ?= 3; + return X.pos == 1; } -test bool isDefinedAnno9() = f3()[@pos = 1] has pos; +test bool isDefinedAnno9() = f3()[pos=1] has pos; // TODO we can not tell this anymore since annotations are now simulated using keyword parameters. // the keyword parameter "is" always there due to their semantics of having defaults.. diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/Sets.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/Sets.rsc index 2b25b92cb0a..4e2eaf4923e 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/Sets.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/Sets.rsc @@ -144,7 +144,8 @@ test bool tst_toList(set[int] S) = isEmpty(S) || size(S) == size(toList(S)) && a test bool tst_toMap(rel[int, int] S) = isEmpty(S) || domain(S) == domain(toMap(S)) && range(S) == {*toMap(S)[k] | k <- toMap(S)}; data X = y(int y); -anno int X@z; + +data X(int z = 0); test bool tst_toMapUnique(set[int] D, set[int] R) { if(isEmpty(D) || isEmpty(R)) return true; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Locations.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Locations.rsc index e0bb0a266f4..449b3cd8b86 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Locations.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Locations.rsc @@ -45,28 +45,28 @@ test bool parsedExpressionsHaveSourceLocations2c() = ([E] "(a+(a*a))").src.length == 9; test bool concreteExpressionsHaveSourceLocationsLegacy1a() - = (A) `a`@\loc?; + = (A) `a`.src?; test bool parsedExpressionsHaveSourceLocationsLegacy1a() - = ([A] "a")@\loc?; + = ([A] "a").src?; test bool concreteExpressionsHaveSourceLocationsLegacy1b() - = (E) `(a+a)`@\loc?; + = (E) `(a+a)`.src?; test bool parsedExpressionsHaveSourceLocationsLegacy1b() - = ([E] "(a+a)")@\loc?; + = ([E] "(a+a)").src?; test bool concreteExpressionsHaveSourceLocationsLegacy1c() - = (E) `(a+(a*a))`@\loc?; + = (E) `(a+(a*a))`.src?; test bool parsedExpressionsHaveSourceLocationsLegacy1c() - = ([E] "(a+(a*a))")@\loc?; + = ([E] "(a+(a*a))").src?; test bool concreteExpressionsSourceLocationsLengthLegacy1a() - = (A) `a`@\loc.length == 1; + = (A) `a`.src.length == 1; test bool parsedExpressionsSourceLocationsLengthLegacy1a() - = ([A] "a")@\loc.length == 1; + = ([A] "a").src.length == 1; test bool concreteExpressionsSourceLocationsLength2a() = (E) `(a+a)`.src.length == 5; @@ -100,7 +100,7 @@ test bool concreteExpressionsAssignSourceLocation1() { test bool concreteExpressionsAssignSourceLocationLegacy1() { x = (A) `a`; - y = x@\loc[length = 100]; + y = x.src[length = 100]; return y.length == 100; } @@ -111,7 +111,7 @@ test bool concreteExpressionsHaveSourceLocationsAfterVisitWithMatch() { case int i => i + 1 } - return t@\loc?; + return t.src?; } test bool concreteExpressionsHaveSourceLocationsAfterVisitWithNoMatch() { @@ -119,6 +119,6 @@ test bool concreteExpressionsHaveSourceLocationsAfterVisitWithNoMatch() { case 1239461234912634 => 123498761234896123 } - return t@\loc?; + return t.src?; } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Patterns3.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Patterns3.rsc index 3c0b2ef1731..746a2227d3f 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Patterns3.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Patterns3.rsc @@ -85,11 +85,7 @@ appl( {}), [appl( regular(\iter-star(lex("LAYOUT"))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,0,<9,9>,<9,9>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,0,<9,9>,<9,9>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,0,<9,9>,<9,9>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,0,<9,9>,<9,9>)],appl( prod( label( "nonterminal", @@ -150,15 +146,7 @@ appl( range(95,95), range(97,122) ]))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(123,0,<9,10>,<9,10>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,1,<9,9>,<9,10>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,1,<9,9>,<9,10>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,1,<9,9>,<9,10>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(123,0,<9,10>,<9,10>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,1,<9,9>,<9,10>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,1,<9,9>,<9,10>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(122,1,<9,9>,<9,10>)],appl( prod( layouts("LAYOUTLIST"), [conditional( @@ -183,11 +171,7 @@ appl( {}), [appl( regular(\iter-star(lex("LAYOUT"))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(123,0,<9,10>,<9,10>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(123,0,<9,10>,<9,10>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(123,0,<9,10>,<9,10>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(123,0,<9,10>,<9,10>)],appl( prod( lit(")"), [\char-class([range(41,41)])], @@ -234,13 +218,7 @@ appl( range(12288,12288) ])], {}), - [char(32)])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(124,1,<9,11>,<9,12>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(124,1,<9,11>,<9,12>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(124,1,<9,11>,<9,12>) - ],appl( + [char(32)])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(124,1,<9,11>,<9,12>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(124,1,<9,11>,<9,12>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(124,1,<9,11>,<9,12>)],appl( prod( lit("`"), [\char-class([range(96,96)])], @@ -305,11 +283,7 @@ appl( {}), [appl( regular(\iter-star(lex("LAYOUT"))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,0,<9,14>,<9,14>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,0,<9,14>,<9,14>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,0,<9,14>,<9,14>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,0,<9,14>,<9,14>)],appl( prod( label( "nonterminal", @@ -370,15 +344,7 @@ appl( range(95,95), range(97,122) ]))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,0,<9,15>,<9,15>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,0,<9,15>,<9,15>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>)],appl( prod( layouts("LAYOUTLIST"), [conditional( @@ -420,13 +386,7 @@ appl( range(12288,12288) ])], {}), - [char(32)])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,1,<9,15>,<9,16>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,1,<9,15>,<9,16>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,1,<9,15>,<9,16>) - ],appl( + [char(32)])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,1,<9,15>,<9,16>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,1,<9,15>,<9,16>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,1,<9,15>,<9,16>)],appl( prod( lex("Name"), [conditional( @@ -492,13 +452,7 @@ appl( range(95,95), range(97,122) ]))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>)],appl( prod( layouts("LAYOUTLIST"), [conditional( @@ -523,29 +477,17 @@ appl( {}), [appl( regular(\iter-star(lex("LAYOUT"))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>)],appl( prod( lit("\>"), [\char-class([range(62,62)])], {}), - [char(62)])])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(126,5,<9,13>,<9,18>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(126,5,<9,13>,<9,18>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(126,5,<9,13>,<9,18>) - ],appl( + [char(62)])])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(126,5,<9,13>,<9,18>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(126,5,<9,13>,<9,18>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(126,5,<9,13>,<9,18>)],appl( prod( lit("`"), [\char-class([range(96,96)])], {}), - [char(96)])])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(121,11,<9,8>,<9,19>) -]; + [char(96)])])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(121,11,<9,8>,<9,19>)]; rel[Tree,Tree] ThePsList = {,<9,15>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>) - ],appl( + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(128,0,<9,15>,<9,15>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(127,1,<9,14>,<9,15>)],appl( prod( lex("Name"), [conditional( @@ -683,10 +617,4 @@ rel[Tree,Tree] ThePsList = range(95,95), range(97,122) ]))), - [])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>) - ]])[ - @\loc=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>) - ]>}; + [])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(130,0,<9,17>,<9,17>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>)]])[src=|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst2.rsc|(129,1,<9,16>,<9,17>)]>}; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax5.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax5.rsc index 951b00d538a..5f05c722b93 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax5.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax5.rsc @@ -20,7 +20,7 @@ test bool concreteFragmentHasSrc() test bool concreteFragmentHasLegacyLoc() = e:(Expression) ` + ` := (Expression) `1 + 2` && - e@\loc? && x@\loc?; + e.src? && x.src?; test bool concreteFragmentHasCorrectSrcs() = e:(Expression) ` + ` := (Expression) `1 + 2` && diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc index cef05682a43..0d5b4f0b3eb 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc @@ -597,12 +597,13 @@ test bool order4()= order(h1(f1(1),g1([h1(f1(2),f1(3)),f1(4),f1(5)]))) == [1,2,3 data NODE = nd(NODE left, NODE right) | leaf(int n); -anno int NODE@pos; + +data NODE(int pos = 0); -NODE N1 = nd(leaf(0)[@pos=0], leaf(1)[@pos=1])[@pos=2]; +NODE N1 = nd(leaf(0)[pos=0], leaf(1)[pos=1])[pos=2]; test bool visitWithAnno1() { - return visit(leaf(1)[@pos=1]){ + return visit(leaf(1)[pos=1]){ case leaf(1) => leaf(10) default:; } @@ -624,7 +625,7 @@ test bool visitWithAnno3() { default:; } == - nd(leaf(0)[@pos=0], leaf(10))[@pos=2]; + nd(leaf(0)[pos=0], leaf(10))[pos=2]; } test bool visitWithAnno4() { @@ -634,7 +635,7 @@ test bool visitWithAnno4() { default:; } == - nd(leaf(0), leaf(10))[@pos=2]; + nd(leaf(0), leaf(10))[pos=2]; } test bool visitWithAnno5() { @@ -649,19 +650,19 @@ test bool visitWithAnno5() { } public &T delAnnotationsRec1(&T v) = visit(v) { - case node n => delAnnotations(n) + case node n => unset(n) }; public &T delAnnotationsRec2(&T v) = visit(v) { - case node n: { insert delAnnotations(n); } + case node n: { insert unset(n); } }; public NODE A1 = leaf(3); -public NODE A2 = leaf(3)[@pos = 1]; +public NODE A2 = leaf(3)[pos=1]; -test bool visitWithAnno6() = !delAnnotationsRec1(A2)@pos?; +test bool visitWithAnno6() = !delAnnotationsRec1(A2).pos?; -test bool visitWithAnno7() = !delAnnotationsRec2(A2)@pos?; +test bool visitWithAnno7() = !delAnnotationsRec2(A2).pos?; // StringVisit1a diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit2.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit2.rsc index 7e188a690a6..b819a46fda8 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit2.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit2.rsc @@ -3,40 +3,23 @@ module lang::rascal::tests::functionality::Visit2 import Grammar; import ParseTree; -anno int Symbol@id; + +data Symbol(int id = 0); Grammar G0 = grammar( - {sort("S")[ - @id=2 - ]}, + {sort("S")[id=2]}, ( - sort("S")[ - @id=3 - ]:choice( - sort("S")[ - @id=4 - ], + sort("S")[id=3]:choice( + sort("S")[id=4], {prod( - sort("S")[ - @id=5 - ], - [lit("0")[ - @id=6 - ]], + sort("S")[id=5], + [lit("0")[id=6]], {})}), - lit("0")[ - @id=7 - ]:choice( - lit("0")[ - @id=8 - ], + lit("0")[id=7]:choice( + lit("0")[id=8], {prod( - lit("0")[ - @id=9 - ], - [\char-class([range(48,48)])[ - @id=10 - ]], + lit("0")[id=9], + [\char-class([range(48,48)])[id=10]], {})}) )); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/Node.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/Node.rsc index 95ccda6cd5c..96e9fb1ef54 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/library/Node.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/Node.rsc @@ -18,52 +18,54 @@ test bool arity3() = arity(xf(1,2)) == 2; // delAnnotation data ANODE = leaf(int n) | a(ANODE left, ANODE right); -anno int ANODE@pos; -anno str ANODE@label; + +data ANODE(int pos = 0); + +data ANODE(str label = ""); public ANODE A1 = leaf(3); -public ANODE A2 = leaf(3)[@pos = 1][@label="a"]; -public ANODE A3 = a(leaf(10)[@pos = 1][@label="a"], leaf(20)[@pos=2][@label="b"])[@pos=3][@label="c"]; +public ANODE A2 = leaf(3)[pos=1][label="a"]; +public ANODE A3 = a(leaf(10)[pos=1][label="a"], leaf(20)[pos=2][label="b"])[pos=3][label="c"]; -test bool delAnnotation1() = !delAnnotation(A1, "pos")@pos?; -test bool delAnnotation2() = !delAnnotation(A2, "pos")@pos?; -test bool delAnnotation3() = delAnnotation(A2, "pos")@label == "a"; -test bool delAnnotation4() = !delAnnotation(A3, "pos")@pos?; -test bool delAnnotation5() = delAnnotation(A3, "pos")@label == "c"; +test bool delAnnotation1() = !delAnnotation(A1, "pos").pos?; +test bool delAnnotation2() = !delAnnotation(A2, "pos").pos?; +test bool delAnnotation3() = delAnnotation(A2, "pos").label == "a"; +test bool delAnnotation4() = !delAnnotation(A3, "pos").pos?; +test bool delAnnotation5() = delAnnotation(A3, "pos").label == "c"; // delAnnotations -test bool delAnnotations1() = !delAnnotations(A1)@pos?; -test bool delAnnotations2() = !delAnnotations(A1)@label?; +test bool delAnnotations1() = !unset(A1).pos?; +test bool delAnnotations2() = !unset(A1).label?; -test bool delAnnotations3() = !delAnnotations(A2)@pos?; -test bool delAnnotations4() = !delAnnotations(A2)@label?; +test bool delAnnotations3() = !unset(A2).pos?; +test bool delAnnotations4() = !unset(A2).label?; -test bool delAnnotations5() = !delAnnotations(A3)@pos?; -test bool delAnnotations6() = !delAnnotations(A3)@label?; +test bool delAnnotations5() = !unset(A3).pos?; +test bool delAnnotations6() = !unset(A3).label?; -test bool delAnnotations7() = ANODE n := delAnnotations(A3)[0] && n@pos == 1; -test bool delAnnotations8() = ANODE n := delAnnotations(A3)[0] && n@label == "a"; +test bool delAnnotations7() = ANODE n := unset(A3)[0] && n.pos == 1; +test bool delAnnotations8() = ANODE n := unset(A3)[0] && n.label == "a"; -test bool delAnnotations9() = ANODE n := delAnnotations(A3)[1] && n@pos == 2; -test bool delAnnotations10() = ANODE n := delAnnotations(A3)[1] && n@label == "b"; +test bool delAnnotations9() = ANODE n := unset(A3)[1] && n.pos == 2; +test bool delAnnotations10() = ANODE n := unset(A3)[1] && n.label == "b"; // delAnnotationsRec -test bool delAnnotationsRec1() = !delAnnotationsRec(A1)@pos?; -test bool delAnnotationsRec2() = !delAnnotationsRec(A1)@label?; +test bool delAnnotationsRec1() = !delAnnotationsRec(A1).pos?; +test bool delAnnotationsRec2() = !delAnnotationsRec(A1).label?; -test bool delAnnotationsRec3() = !delAnnotationsRec(A2)@pos?; -test bool delAnnotationsRec4() = !delAnnotationsRec(A2)@label?; +test bool delAnnotationsRec3() = !delAnnotationsRec(A2).pos?; +test bool delAnnotationsRec4() = !delAnnotationsRec(A2).label?; -test bool delAnnotationsRec5() = !delAnnotationsRec(A3)@pos?; -test bool delAnnotationsRec6() = !delAnnotationsRec(A3)@label?; +test bool delAnnotationsRec5() = !delAnnotationsRec(A3).pos?; +test bool delAnnotationsRec6() = !delAnnotationsRec(A3).label?; -test bool delAnnotationsRec7() = ANODE n := delAnnotationsRec(A3)[0] && !n@pos?; -test bool delAnnotationsRec8() = ANODE n := delAnnotationsRec(A3)[0] && !n@label?; +test bool delAnnotationsRec7() = ANODE n := delAnnotationsRec(A3)[0] && !n.pos?; +test bool delAnnotationsRec8() = ANODE n := delAnnotationsRec(A3)[0] && !n.label?; -test bool delAnnotationsRec9() = ANODE n := delAnnotationsRec(A3)[1] && !n@pos?; -test bool delAnnotationsRec10() = ANODE n := delAnnotationsRec(A3)[1] && !n@label?; +test bool delAnnotationsRec9() = ANODE n := delAnnotationsRec(A3)[1] && !n.pos?; +test bool delAnnotationsRec10() = ANODE n := delAnnotationsRec(A3)[1] && !n.label?; // getAnnotations test bool getAnnotations1() = getAnnotations(A1) == (); @@ -103,8 +105,8 @@ test bool makeNode4() {node n = makeNode("f", 1, 2, 3); return getName(n) == "f" // setAnnotations test bool setAnnotations1() = setAnnotations(leaf(3), ()) == leaf(3); -test bool setAnnotations2() = setAnnotations(leaf(3), ("pos": 1, "label":"a"))@pos == 1; -test bool setAnnotations3() = setAnnotations(leaf(3), ("pos": 1, "label":"a"))@label == "a"; +test bool setAnnotations2() = setAnnotations(leaf(3), ("pos": 1, "label":"a")).pos == 1; +test bool setAnnotations3() = setAnnotations(leaf(3), ("pos": 1, "label":"a")).label == "a"; // unset diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc index 60c258340d5..7821daf9718 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc @@ -3,13 +3,14 @@ module lang::rascal::upgrade::UpgradeAnnotationsToKeywordParameters extend lang::rascal::upgrade::UpgradeBase; -anno loc Tree@\loc; + +data Tree(loc src = |unknown:///|); list[Message] report(Tree m) - = [info("found annotation definition", name@\loc) | /(Declaration) ` anno @;` := m] - + [info("found annotation use", name@\loc) | /(Expression) `@` := m] - + [info("found annotion literal", name@\loc) | /(Expression) `[@=]` := m] - + [info("found annotation update", field@\loc) | /(Assignable) `@` := m] + = [info("found annotation definition", name.src) | /(Declaration) ` anno @;` := m] + + [info("found annotation use", name.src) | /(Expression) `@` := m] + + [info("found annotion literal", name.src) | /(Expression) `[@=]` := m] + + [info("found annotation update", field.src) | /(Assignable) `@` := m] ; Tree update(Tree m) = diff --git a/src/org/rascalmpl/library/lang/sdf2/filters/DetectCycles.rsc b/src/org/rascalmpl/library/lang/sdf2/filters/DetectCycles.rsc index ac70f6ff340..46c24f20b10 100644 --- a/src/org/rascalmpl/library/lang/sdf2/filters/DetectCycles.rsc +++ b/src/org/rascalmpl/library/lang/sdf2/filters/DetectCycles.rsc @@ -4,7 +4,7 @@ import ParseTree; &T<:Tree cycleDetectionFilter(amb(set[&T<:Tree] alts)) { if (/t:cycle(_,_) <- alts) { - throw "Cycle detected at "; + throw "Cycle detected at "; } else { fail cycleDetectionFilter; diff --git a/src/org/rascalmpl/library/vis/Basic.rsc b/src/org/rascalmpl/library/vis/Basic.rsc index ec25eea83ab..44afc4db4e9 100644 --- a/src/org/rascalmpl/library/vis/Basic.rsc +++ b/src/org/rascalmpl/library/vis/Basic.rsc @@ -164,7 +164,7 @@ HTMLElement toHTML(t:) HTMLElement toHTML(Tree t:appl(Production p, list[Tree] args)) = div([ text(topProd2rascal(p)), - *(t@\loc? ? [toHTML(t@\loc)] : []), + *(t.src? ? [toHTML(t.src)] : []), ul([ li([toHTML(a)]) | a <- args diff --git a/src/org/rascalmpl/library/vis/Text.rsc b/src/org/rascalmpl/library/vis/Text.rsc index 566a229c92d..083c57b9d28 100644 --- a/src/org/rascalmpl/library/vis/Text.rsc +++ b/src/org/rascalmpl/library/vis/Text.rsc @@ -50,7 +50,7 @@ str prettyTree(Tree t, bool src=false, bool characters=true, bool \layout=false, str nodeLabel(loc src) = ""; default str nodeLabel(Tree v) = ""; - lrel[str,value] edges(Tree t:appl(_, list[Tree] args)) = [<"src", t@\loc> | src, t@\loc?] + [<"", k> | Tree k <- args, include(k)]; + lrel[str,value] edges(Tree t:appl(_, list[Tree] args)) = [<"src", t.src> | src, t.src?] + [<"", k> | Tree k <- args, include(k)]; lrel[str,value] edges(amb(set[Tree] alts)) = [<"", a> | Tree a <- alts]; lrel[str,value] edges(loc _) = []; default lrel[str,value] edges(Tree _) = []; From be67999889d1410f02fec31dbc22fd95c38cf1b0 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 10:06:59 +0200 Subject: [PATCH 05/13] folded src kw parameter into the primary definition of Tree --- src/org/rascalmpl/library/ParseTree.rsc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/org/rascalmpl/library/ParseTree.rsc b/src/org/rascalmpl/library/ParseTree.rsc index ab05f26df22..173f73d4f4c 100644 --- a/src/org/rascalmpl/library/ParseTree.rsc +++ b/src/org/rascalmpl/library/ParseTree.rsc @@ -154,7 +154,7 @@ A `Tree` defines the trees normally found after parsing; additional constructors <4> A single character. } -data Tree //(loc src = |unknown:///|(0,0,<0,0>,<0,0>)) +data Tree(loc src = |unknown:///|(0,0,<0,0>,<0,0>)) = appl(Production prod, list[Tree] args) // <1> | cycle(Symbol symbol, int cycleLength) // <2> | amb(set[Tree] alternatives) // <3> @@ -328,11 +328,6 @@ Production associativity(Symbol rhs, Associativity a, {associativity(rhs, Associ Production associativity(Symbol s, Associativity as, {*Production a, priority(Symbol t, list[Production] b)}) = associativity(s, as, {*a, *b}); - -@synopsis{Annotate a parse tree node with a source location.} -data Tree(loc src = |unknown:///|); - - @synopsis{Parse input text (from a string or a location) and return a parse tree.} @description{ * Parse a string and return a parse tree. From 8e56720d7401cfa9874e83ac0e18393ea443872b Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 10:09:55 +0200 Subject: [PATCH 06/13] added deprecation messages of old annotations/keyword parameters that _only_ work for Eclipse. We can upgrade Eclipse to also use util::IDEServices and util::LanguageServer, or we can drop them as soon as we drop Eclipse --- src/org/rascalmpl/library/ParseTree.rsc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/org/rascalmpl/library/ParseTree.rsc b/src/org/rascalmpl/library/ParseTree.rsc index 173f73d4f4c..c485136a9b5 100644 --- a/src/org/rascalmpl/library/ParseTree.rsc +++ b/src/org/rascalmpl/library/ParseTree.rsc @@ -688,45 +688,45 @@ java &T<:value implode(type[&T<:value] t, Tree tree); @synopsis{Annotate a parse tree node with an (error) message.} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(Message message = Message () { throw "no default value"; }()); @synopsis{Annotate a parse tree node with a list of (error) messages.} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(set[Message] messages = {}); @synopsis{Annotate a parse tree node with a documentation string.} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(str doc = ""); @synopsis{Annotate a parse tree node with documentation strings for several locations.} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(map[loc,str] docs = ()); - - @synopsis{Annotate a parse tree node with the target of a reference.} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(loc link = |unknown:///|); @synopsis{Annotate a parse tree node with multiple targets for a reference.} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(set[loc] links = {}); -@synopsis{Annotate the top of the tree with hyperlinks between entities in the tree (or other trees) - -This is similar to link and links annotations, except that you can put it as one set at the top of the tree.} +@synopsis{Annotate the top of the tree with hyperlinks between entities in the tree (or other trees)} +@description{ +This is similar to link and links annotations, except that you can put it as one set at the top of the tree. +} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(rel[loc,loc] hyperlinks = {}); - @synopsis{Tree search result type for ((treeAt)).} data TreeSearchResult[&T<:Tree] = treeFound(&T tree) | treeNotFound(); - - @synopsis{Select the innermost Tree of a given type which is enclosed by a given location.} -@description{ - -} TreeSearchResult[&T<:Tree] treeAt(type[&T<:Tree] t, loc l, Tree a:appl(_, _)) { if ((a.src)?, al := a.src, al.offset <= l.offset, al.offset + al.length >= l.offset + l.length) { for (arg <- a.args, TreeSearchResult[&T<:Tree] r:treeFound(&T<:Tree _) := treeAt(t, l, arg)) { @@ -749,7 +749,6 @@ bool sameType(conditional(Symbol s,_), Symbol t) = sameType(s,t); bool sameType(Symbol s, s) = true; default bool sameType(Symbol s, Symbol t) = false; - @synopsis{Determine if the given type is a non-terminal type.} bool isNonTerminalType(Symbol::\sort(str _)) = true; bool isNonTerminalType(Symbol::\lex(str _)) = true; From af17d9c955b21b80ab5979f019d1b097bfc2621f Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 11:13:22 +0200 Subject: [PATCH 07/13] added catch NoSuchAnnotation reporter and rewriter and fixed some test --- .../lang/rascal/tests/functionality/Annotation.rsc | 12 ++++-------- .../UpgradeAnnotationsToKeywordParameters.rsc | 6 ++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc index 6727d3c0eed..e4b7f6aa330 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Annotation.rsc @@ -91,12 +91,7 @@ test bool KeywordAssignVisibleViaAnno2(){ test bool unavailableAnno1(){ F example = f(); - try { - example.notThere; - return false; - } - catch NoSuchAnnotation("notThere"): - return true; + return example.notThere == 0 && !(example.notThere?); } test bool unavailableAnno2(){ @@ -108,7 +103,8 @@ test bool unavailableAnno2(){ x.notThere; return false; } - catch NoSuchField("notThere"): - return true; + catch NoSuchField("notThere") : + // TODO: where annotations would often throw exceptions, keyword fields return their default. + return true; } diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc index 7821daf9718..9a85e6f7d47 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc @@ -11,6 +11,7 @@ list[Message] report(Tree m) + [info("found annotation use", name.src) | /(Expression) `@` := m] + [info("found annotion literal", name.src) | /(Expression) `[@=]` := m] + [info("found annotation update", field.src) | /(Assignable) `@` := m] + + [info("found annotation catch", e.src) | /(Catch) `catch NoSuchAnnotation() : ` := m] ; Tree update(Tree m) = @@ -33,6 +34,11 @@ Tree update(Tree m) = case (Assignable) `@` => (Assignable) `.` when Name name2 := getName(field) + + case (Catch) `catch NoSuchAnnotation() : ` + => (Catch) `catch NoSuchField() : + ' // TODO: where annotations would often throw exceptions, keyword fields return their default. + ' ` }; Name getName((Name) `\\loc`) = (Name) `src`; From c00ab61ef4acfc97ec41ef97da1e100f887cffb5 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 11:16:42 +0200 Subject: [PATCH 08/13] better nameTest --- .../rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc index 9a85e6f7d47..957c976c869 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc @@ -46,7 +46,7 @@ Name getName((Name) `src`) = (Name) `src`; Name getName((Name) `location`) = (Name) `src`; default Name getName(Name n) = n; -test bool nameTest() = getName((Name) `location`) == (Name) `src`; +test bool nameTest() = getName((Name) `location`) := (Name) `src`; Expression getInitializer((Type) `rel[<{TypeArg ","}* elem>]`) = (Expression) `{}`; Expression getInitializer((Type) `list[]`) = (Expression) `[]`; From 08da919c9d0c28a827cb38dfd5040cb8740a6c45 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 11:49:22 +0200 Subject: [PATCH 09/13] upgrade reporter now has a progress bar --- .../UpgradeAnnotationsToKeywordParameters.rsc | 10 ++++----- .../lang/rascal/upgrade/UpgradeBase.rsc | 21 +++++++++++++++++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc index 957c976c869..342ee9585e9 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc @@ -2,15 +2,13 @@ module lang::rascal::upgrade::UpgradeAnnotationsToKeywordParameters extend lang::rascal::upgrade::UpgradeBase; - - -data Tree(loc src = |unknown:///|); +import ParseTree; list[Message] report(Tree m) - = [info("found annotation definition", name.src) | /(Declaration) ` anno @;` := m] + = [info("found " == "node") {>irreplacable<}> annotation definition", name.src) | /(Declaration) ` anno @;` := m] + [info("found annotation use", name.src) | /(Expression) `@` := m] - + [info("found annotion literal", name.src) | /(Expression) `[@=]` := m] - + [info("found annotation update", field.src) | /(Assignable) `@` := m] + + [info("found annotion update", name.src) | /(Expression) `[@=]` := m] + + [info("found annotation literal", field.src) | /(Assignable) `@` := m] + [info("found annotation catch", e.src) | /(Catch) `catch NoSuchAnnotation() : ` := m] ; diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc index 42d986854cc..95935de757c 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc @@ -7,9 +7,26 @@ import ParseTree; import IO; import Message; import Exception; +import util::Reflective; +import Set; +import util::Monitor; -list[Message] report(loc root) - = [*reportFor(m) | m <- find(root, "rsc")]; +list[Message] reportForProject(str projectName) + = reportForPathConfig(getProjectPathConfig(|project://|)); + +list[Message] reportForPathConfig(PathConfig pcfg) + = [ *report(root) | root <- pcfg.srcs]; + +list[Message] report(loc root) { + set[loc] ms = find(root, "rsc"); + + return job("Reporting", list[Message] (void (str, int) step) { + bool st(str msg) { step(msg, 1); return true; }; + + list[Message] result = [*reportFor(\module) | \module <- ms, st(\module.file)]; + return result; + }, totalWork = size(ms)); +} list[Message] reportFor(loc l) { try { From 93508eae8d0245febbca167323d8465aaf107313 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 13:21:28 +0200 Subject: [PATCH 10/13] upgraders also have a progress bar --- .../lang/rascal/upgrade/UpgradeBase.rsc | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc index 95935de757c..b7f1af1166d 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc @@ -20,11 +20,10 @@ list[Message] reportForPathConfig(PathConfig pcfg) list[Message] report(loc root) { set[loc] ms = find(root, "rsc"); - return job("Reporting", list[Message] (void (str, int) step) { + return job("Reporting for ", list[Message] (void (str, int) step) { bool st(str msg) { step(msg, 1); return true; }; - list[Message] result = [*reportFor(\module) | \module <- ms, st(\module.file)]; - return result; + return [*reportFor(\module) | \module <- ms, st(\module.file)]; }, totalWork = size(ms)); } @@ -34,17 +33,38 @@ list[Message] reportFor(loc l) { } catch ParseError(loc r) : return [warning("parse error in Rascal file",r)]; } - -void update(loc root) { - modules = [ f | /file(f) := crawl(root), f.extension == "rsc"]; - for (m <- modules) { - try - writeFile(m, ""); - catch ParseError(l): - println("parse error in , skipped"); + +void updateProject(str projectName) { + updatePathConfig(getProjectPathConfig(|project://|)); +} + +void updatePathConfig(PathConfig pcfg) { + for (root <- pcfg.srcs) { + update(root); } } -default list[Message] report(Tree m) = []; +void update(loc root) { + set[loc] ms = find(root, "rsc"); + + job("Updating ", bool (void (str, int) step) { + for (loc m <- ms) { + try { + step(m.file, 1); + writeFile(m, ""); + } + catch ParseError(l): { + println("parse error in , skipped"); + } + } + + return true; + }, totalWork=size(ms)); +} + +@synopsis{Definition to override in an extending module for reporting on a specific upgrade refactoring.} +default list[Message] report(Tree _) = []; + +@synopsis{Definition to override in an extending module for implementing a specific upgrade refactoring.} default Tree update(Tree m) = m; From 90b0a71a135a12ed3c1eb70a88424d75a0a96fde Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 13:39:43 +0200 Subject: [PATCH 11/13] fixed type check error --- src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc index b7f1af1166d..c4d7959aaa9 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc @@ -40,11 +40,11 @@ void updateProject(str projectName) { void updatePathConfig(PathConfig pcfg) { for (root <- pcfg.srcs) { - update(root); + updateFolder(root); } } -void update(loc root) { +void updateFolder(loc root) { set[loc] ms = find(root, "rsc"); job("Updating ", bool (void (str, int) step) { From 88c41aa2441269c259fb6be3fd692cb6c41e5c7e Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 12 Jun 2024 15:53:04 +0200 Subject: [PATCH 12/13] fixing tests and improving refactorings --- src/org/rascalmpl/library/ParseTree.rsc | 1 - .../rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc | 2 +- .../library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc | 1 - src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc | 3 +++ 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/library/ParseTree.rsc b/src/org/rascalmpl/library/ParseTree.rsc index c485136a9b5..4d6a9cc425d 100644 --- a/src/org/rascalmpl/library/ParseTree.rsc +++ b/src/org/rascalmpl/library/ParseTree.rsc @@ -691,7 +691,6 @@ java &T<:value implode(type[&T<:value] t, Tree tree); @deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(Message message = Message () { throw "no default value"; }()); - @synopsis{Annotate a parse tree node with a list of (error) messages.} @deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} data Tree(set[Message] messages = {}); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc index 4af37b03f5e..178a39c03e3 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc @@ -244,7 +244,7 @@ test bool tst() { int x = 10; y = x ? 1; return y == 10; } data F = f3() | f3(int n) | g(int n) | deep(F f); -data F(int pos = 0); +data F(int pos = 10); test bool isDefinedAnno1() = (f3()[pos=1]).pos?; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc index 91986edf554..1ecd41929c3 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc @@ -1,6 +1,5 @@ module lang::rascal::tests::concrete::SyntaxKeywordFields -import Node; import ParseTree; syntax A = "a"; diff --git a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc index c4d7959aaa9..df18e1ceeb2 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeBase.rsc @@ -11,6 +11,9 @@ import util::Reflective; import Set; import util::Monitor; +list[Message] reportForProject(loc projectRoot) + = reportForPathConfig(getProjectPathConfig(projectRoot)); + list[Message] reportForProject(str projectName) = reportForPathConfig(getProjectPathConfig(|project://|)); From eafd290aa5b9d31b6acc2fdc82cbf9ead278e85c Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Mon, 17 Jun 2024 11:37:46 +0200 Subject: [PATCH 13/13] made tests work better without annotations --- src/org/rascalmpl/library/ParseTree.rsc | 6 +++++- .../lang/rascal/tests/concrete/SyntaxKeywordFields.rsc | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/library/ParseTree.rsc b/src/org/rascalmpl/library/ParseTree.rsc index 4d6a9cc425d..2d22380f661 100644 --- a/src/org/rascalmpl/library/ParseTree.rsc +++ b/src/org/rascalmpl/library/ParseTree.rsc @@ -687,9 +687,13 @@ data Exp = add(Exp, Exp); java &T<:value implode(type[&T<:value] t, Tree tree); +@synopsis{A bottom value for Message is interpreted as no message at all.} +@deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} +data Message = silence(); + @synopsis{Annotate a parse tree node with an (error) message.} @deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} -data Tree(Message message = Message () { throw "no default value"; }()); +data Tree(Message message = silence()); @synopsis{Annotate a parse tree node with a list of (error) messages.} @deprecated{Use util::LanguageServer and util::IDEServices instead. This only works in Eclipse.} diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc index 1ecd41929c3..d0290e58f0d 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/SyntaxKeywordFields.rsc @@ -5,7 +5,7 @@ import ParseTree; syntax A = "a"; syntax B = "b" | [b]; // ambiguous on purpose -// we only allow declarations on Tree for now, for lack of a syntax to declare them on non-terminals. +// we only allow keyword parameters on Tree for now, for lack of a syntax to declare them on non-terminals. data Tree(str y = "y"); &T<:Tree get(&T<:Tree e) = e;