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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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; From e915560c6d6b15ea8452ce832c5016897c7f4a87 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 7 Apr 2026 14:26:53 +0200 Subject: [PATCH 14/16] re-applied anno to kw field upgrade tool to the library after merging main --- .../lang/rascalcore/check/ADTandGrammar.rsc | 2 +- .../lang/rascalcore/check/Checker.rsc | 8 +- .../lang/rascalcore/check/RascalConfig.rsc | 4 +- .../check/tests/StaticTestingUtils.rsc | 16 +- .../Rascal2muRascal/ConcreteSyntax.rsc | 30 ++-- .../Rascal2muRascal/RascalDeclaration.rsc | 10 +- .../Rascal2muRascal/RascalExpression.rsc | 150 +++++++++--------- .../compile/Rascal2muRascal/RascalModule.rsc | 10 +- .../compile/Rascal2muRascal/RascalPattern.rsc | 114 ++++++------- .../Rascal2muRascal/RascalStatement.rsc | 66 ++++---- .../compile/Rascal2muRascal/RascalType.rsc | 2 +- .../compile/Rascal2muRascal/TypeUtils.rsc | 4 +- .../lang/rascalcore/compile/muRascal/AST.rsc | 2 +- .../compile/muRascal2Java/Conversions.rsc | 2 +- .../lang/rascalcore/package/Packager.rsc | 6 +- src/org/rascalmpl/library/ParseTree.rsc | 18 +-- .../analysis/diff/edits/HiFiLayoutDiff.rsc | 10 +- .../analysis/diff/edits/HiFiTreeDiff.rsc | 22 +-- .../library/lang/pico/format/Formatting.rsc | 2 +- .../rascal/tests/basic/RepositionTree.rsc | 4 +- .../concrete/recovery/bugs/MultiErrorBug.rsc | 4 +- .../lang/rascal/tutor/apidoc/ExtractInfo.rsc | 14 +- .../rascal/tutor/conversions/SplitDocTag.rsc | 4 +- .../lang/rascal/tutor/conversions/TrimDoc.rsc | 2 +- 24 files changed, 253 insertions(+), 253 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc index 1f2f3564282..88bdb54e5fb 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc @@ -100,7 +100,7 @@ void addCommonKeywordFields(Solver s){ fieldName = ""; fieldType = s.getType(kwf); fieldType.alabel = fieldName; - moduleName = getRascalModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig); + moduleName = getRascalModuleName(kwf.expression.src, s.getConfig().typepalPathConfig); commonKeywordFields += ; //commonKeywordFieldNames += ; // TODO: reconsider this diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc index 98ec75730d4..a6363b66e7c 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc @@ -318,14 +318,14 @@ ModuleStatus rascalTModelForLocs( = getModuleParseTree(m, ms); if(success){ if(compilerConfig.infoModuleChecked){ - imsgs += [info("Checked ", pt.header.name@\loc)]; + imsgs += [info("Checked ", pt.header.name.src)]; } check_imports: for(imod <- pt.header.imports, imod has \module){ iname = unescape(""); inameId = moduleName2moduleId(iname); if(hasProperty(inameId, ms, tpl_version_error(), rsc_not_found())){ - imsgs += error("Rascal TPL version error for ``, no source found", imod@\loc); + imsgs += error("Rascal TPL version error for ``, no source found", imod.src); } if(inameId notin usedModules){ if(iname == "ParseTree" && implicitlyUsesParseTree(ms.moduleLocs[m].path, tm)){ @@ -339,7 +339,7 @@ ModuleStatus rascalTModelForLocs( } if((inameId in component || hasProperty(inameId, ms, checked())) && hasNotProperty(inameId, ms, rsc_not_found())){ if(imod is \default){ - imsgs += warning("Unused import of ``", imod@\loc); + imsgs += warning("Unused import of ``", imod.src); } //else { //TODO: maybe add option to turn off info messages? //imsgs += info("Extended module `` is unused in the current module", imod@\loc); //} @@ -469,7 +469,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[MODID] moduleIds, ModuleSt tagsMap = getTags(pt.header.tags); if(hasIgnoreCompilerTag(tagsMap)) { - ms.messages[mid] ? {} += { Message::info("Ignoring module ", pt.header.name@\loc) }; + ms.messages[mid] ? {} += { Message::info("Ignoring module ", pt.header.name.src) }; ms = addProperty(mid, ms, ModuleProperty::ignored()); } idTrees[mid] = pt; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc index 6e1f3894d83..122983e1d82 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc @@ -411,7 +411,7 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){ set[Define] defines = s.getAllDefines(); facts = s.getFacts(); - moduleScopes = { t@\loc | t <- range(namedTrees) }; + moduleScopes = { t.src | t <- range(namedTrees) }; funDefs = { | define <- defines, define.idRole == functionId() }; funIds = domain(funDefs); @@ -516,7 +516,7 @@ void reportConstructorOverload(Expression current, overloadedAType(rel[loc def, qualifyHint = size(adtNames) > 1 ? " you may use as qualifier" : ""; argHint = "make argument type(s) more precise"; msg = error("Constructor `` is overloaded, maybe", - current@\loc); + current.src); s.addMessages([msg]); } } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc index b08093c2d77..df71ace585e 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc @@ -204,21 +204,21 @@ bool validateUseDefs(str moduleName, map[str, tuple[int, set[int]]] defuses, Mod map[loc, str] loc2name = (); top-down-break visit(pt){ case Name nm: { - names[""] ? [] += [nm@\loc]; - loc2name[nm@\loc] = ""; + names[""] ? [] += [nm.src]; + loc2name[nm.src] = ""; } case QualifiedName nm: { - names[""] ? [] += [nm@\loc]; - loc2name[nm@\loc] = ""; + names[""] ? [] += [nm.src]; + loc2name[nm.src] = ""; } case Nonterminal nm: { - names[""] ? [] += [nm@\loc]; - loc2name[nm@\loc] = ""; + names[""] ? [] += [nm.src]; + loc2name[nm.src] = ""; } case NonterminalLabel nm: { - names[""] ? [] += [nm@\loc]; - loc2name[nm@\loc] = ""; + names[""] ? [] += [nm.src]; + loc2name[nm.src] = ""; } } println("names:"); iprintln(names); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/ConcreteSyntax.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/ConcreteSyntax.rsc index 09976df45c5..44a96bc7f94 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/ConcreteSyntax.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/ConcreteSyntax.rsc @@ -55,25 +55,25 @@ tuple[Tree, TModel] parseConcreteFragments(Tree M, TModel tm, AGrammar gr) { @doc{parse fragment or store parse error in the TModel} Tree parseFragment(t:appl(prod(label("typed",lex("Concrete")), _, _),[_,_,Tree varsym,_,_,_,_, parts,_])) { try { - sym = atype2symbol(getType(varsym@\loc)); + sym = atype2symbol(getType(varsym.src)); return appl(prod(label("parsed",Symbol::lex("Concrete")), [sym], {}), [ doParseFragment(sym, parts.args, rules) - ])[@\loc=t@\loc]; + ])[src=t.src]; } catch ParseError(_) : { - throw CompileTimeError(error("Parse error in concrete syntax fragment `

<}>`", t@\loc)); + throw CompileTimeError(error("Parse error in concrete syntax fragment `

<}>`", t.src)); } catch Ambiguity(loc _location, str nonterminal, str sentence): { - throw CompileTimeError(error("Ambiguity in concrete syntax fragment for : ``", /*location*/ t@\loc)); + throw CompileTimeError(error("Ambiguity in concrete syntax fragment for : ``", /*location*/ t.src)); } } - ignoredFunctionLocs = {fd@\loc | /FunctionDeclaration fd := M, hasIgnoreCompilerTag(getTags(fd.tags)) }; + ignoredFunctionLocs = {fd.src | /FunctionDeclaration fd := M, hasIgnoreCompilerTag(getTags(fd.tags)) }; M = top-down-break visit(M) { case Tree t:appl(p:prod(label("concrete",sort(/Expression|Pattern/)), _, _),[Tree concrete]) - => appl(p, [parseFragment(concrete)])[@\loc=t@\loc] - when !any(loc ign <- ignoredFunctionLocs, isContainedIn(t@\loc, ign, tm.logical2physical)) + => appl(p, [parseFragment(concrete)])[src=t.src] + when !any(loc ign <- ignoredFunctionLocs, isContainedIn(t.src, ign, tm.logical2physical)) } return ; @@ -96,7 +96,7 @@ Tree doParseFragment(Symbol sym, list[Tree] parts, map[Symbol, Production] rules // here we weave in a unique and indexed sub-string for which a special rule // was added by the parser generator: - holeType = atype2symbol(getType(hole.args[2]@\loc)); + holeType = atype2symbol(getType(hole.args[2].src)); return "\u0000:\u0000"; } @@ -106,9 +106,9 @@ Tree doParseFragment(Symbol sym, list[Tree] parts, map[Symbol, Production] rules // now parse the input to get a Tree (or a ParseError is thrown) if(type[Tree] tp := type(sym, rules)){ Tree tree = ParseTree::parse(tp, input, |todo:///|); - return isEmpty(parts) ? tree : restoreHoles(tree, holes, parts[0]@\loc); + return isEmpty(parts) ? tree : restoreHoles(tree, holes, parts[0].src); } else { - throw InternalCompilerError(error("Illegal type in concrete syntax fragment `

<}>`", parts[0]@\loc)); + throw InternalCompilerError(error("Illegal type in concrete syntax fragment `

<}>`", parts[0].src)); } } @@ -147,10 +147,10 @@ RestoreState restoreHoles(t:char(int c), map[int, Tree] _, loc _, int offset, in RestoreState restoreHoles(Tree v:appl(prod(Symbol::label("$MetaHole", Symbol varType), _, {\tag("holeType"(Symbol ht))}), [char(0),_,_,Tree i,char(0)]), map[int, Tree] holes, loc _, int _, int _, int _) { Tree typedVar = holes[toInt("")]; - return ; } @@ -165,7 +165,7 @@ default RestoreState restoreHoles(Tree v:appl(Production p, list[Tree] args), ma append a; } - return , )], + return , )], curOffset, curLine, curColumn>; } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc index 7a92a6cf657..3b0b3e885c6 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc @@ -139,7 +139,7 @@ private void generateGettersForAdt(AType adtType, loc module_scope, set[AType] c */ consName = consType.alabel; - for(kw <- consType.kwFields, kw has defaultExp, isContainedIn(kw.defaultExp@\loc, module_scope, l2p)){ + for(kw <- consType.kwFields, kw has defaultExp, isContainedIn(kw.defaultExp.src, module_scope, l2p)){ kwType = kw.fieldType; defaultExp = kw.defaultExp; str kwFieldName = kwType.alabel; @@ -176,7 +176,7 @@ private void generateGettersForAdt(AType adtType, loc module_scope, set[AType] c getterType = afunc(returnType, [adtType], []); adtVar = muVar(adtName, getterName, 0, adtType, dataId()); failCode = muFailReturn(returnType); - for(Keyword kw <- common_keyword_fields, kw has defaultExp, isContainedIn(kw.defaultExp@\loc, module_scope, l2p)){ + for(Keyword kw <- common_keyword_fields, kw has defaultExp, isContainedIn(kw.defaultExp.src, module_scope, l2p)){ kwType = kw.fieldType; str commonKwFieldName = unescape(kwType.alabel); if(commonKwFieldName == kwFieldName){ @@ -198,7 +198,7 @@ private void generateGettersForAdt(AType adtType, loc module_scope, set[AType] c * Create getters for common keyword fields of this data type */ seen = {}; - for(Keyword kw <- common_keyword_fields, kw has defaultExp, kw.fieldType notin seen, isContainedIn(kw.defaultExp@\loc, module_scope, l2p)){ + for(Keyword kw <- common_keyword_fields, kw has defaultExp, kw.fieldType notin seen, isContainedIn(kw.defaultExp.src, module_scope, l2p)){ kwType = kw.fieldType; defaultExp = kw.defaultExp; seen += kwType; @@ -491,8 +491,8 @@ public tuple[list[MuExp] formalVars, MuExp funBody] translateFunction(str fname, formalVars = for(i <- index(formalsList)){ pname = getParameterName(formalsList, i); ndummies += size(dummyFormalsInType(getType(formalsList[i]))); - if(hasParameterName(formalsList, i) && !isUse(formalsList[i]@\loc)){ - pos = getPositionInScope(pname, getParameterNameAsTree(formalsList, i)@\loc); + if(hasParameterName(formalsList, i) && !isUse(formalsList[i].src)){ + pos = getPositionInScope(pname, getParameterNameAsTree(formalsList, i).src); //println(": pos = , ndummies = , pos - ndummies = "); //if(pos - ndummies > 0) pos -= ndummies; append muVar(pname, fuid, pos, unsetRec(getType(formalsList[i]), "alabel"), formalId()); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc index 962ad8c0c30..1305424ad38 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc @@ -74,10 +74,10 @@ import lang::rascalcore::compile::Rascal2muRascal::RascalConstantCall; // Generate code for completely type-resolved operators private MuExp infix(str op, Expression e) { - return muPrim(op, getType(e), [getType(e.lhs), getType(e.rhs)], [translate(e.lhs), translate(e.rhs)], e@\loc); + return muPrim(op, getType(e), [getType(e.lhs), getType(e.rhs)], [translate(e.lhs), translate(e.rhs)], e.src); } private MuExp unary(str op, Expression e, Expression arg) = - muPrim(op, getType(e), [getType(arg)], [translate(arg)], e@\loc); + muPrim(op, getType(e), [getType(arg)], [translate(arg)], e.src); // ----------- compose: exp o exp ---------------- @@ -129,7 +129,7 @@ private MuExp translateAddFunction(Expression e){ // Generate and add a function ADD<...> str scopeId = topFunctionScope(); - str add_name = "$ADDAL"; + str add_name = "$ADDAL"; str add_fuid = scopeId + "_" + add_name; MuExp lhsReceiver = translate(e.lhs); @@ -139,21 +139,21 @@ private MuExp translateAddFunction(Expression e){ lhsFormals = getFormals(lhsType); nargs = size(lhsFormals); lactuals = [muVar("$", add_fuid, j, lhsFormals[j], formalId()) | int j <- [0 .. nargs]]; - lhsCall = muOCall(lhsReceiver, lhsType, lactuals, [], e.lhs@\loc); + lhsCall = muOCall(lhsReceiver, lhsType, lactuals, [], e.lhs.src); rhsFormals = getFormals(rhsType); nargs = size(rhsFormals); ractuals = [muVar("$" , add_fuid, j, rhsFormals[j], formalId()) | int j <- [0 .. nargs]]; - rhsCall = muOCall(rhsReceiver, rhsType, ractuals, [], e.rhs@\loc); + rhsCall = muOCall(rhsReceiver, rhsType, ractuals, [], e.rhs.src); body = muReturnFirstSucceeds(["$" | int i <- [0 .. nargs]], [muReturn1(resType, lhsCall), muReturn1(resType, rhsCall)]); leaveFunctionScope(); funType = afunc(resType, lhsFormals, []); - fun = muFunction(add_name, add_name, funType, lactuals, [], [], scopeId, false, false, false, getExternalRefs(body, add_fuid, []), {}, {}, e@\loc, [], (), body); - loc uid = declareGeneratedFunction(add_name, add_fuid, funType, e@\loc); + fun = muFunction(add_name, add_name, funType, lactuals, [], [], scopeId, false, false, false, getExternalRefs(body, add_fuid, []), {}, {}, e.src, [], (), body); + loc uid = declareGeneratedFunction(add_name, add_fuid, funType, e.src); addFunctionToModule(fun); - addDefineAndType(, funType); // TODO: replace arbitrary number + addDefineAndType(, funType); // TODO: replace arbitrary number return muOFun([uid], funType); } @@ -425,7 +425,7 @@ private MuExp toIString(MuExp e, loc src) private MuExp translateToIString(Expression e) = isStrAType(getType(e)) ? translate(e) - : muPrim("toIString", astr(), [avalue()], [translate(e)], e@\loc); + : muPrim("toIString", astr(), [avalue()], [translate(e)], e.src); private MuExp translateLocationLiteral(l: (LocationLiteral) ` `) = muPrim("create_loc", aloc(), [astr()], @@ -433,27 +433,27 @@ private MuExp translateLocationLiteral(l: (LocationLiteral) ``) = muCon(""[1..]); private MuExp translateProtocolPart(p: (ProtocolPart) ` `) = - muPrim("add", astr(), [astr(), astr(), astr()], [muCon("

"[1..-1]), translateToIString(expression), translateProtocolTail(tail)], p@\loc);
+    muPrim("add", astr(), [astr(), astr(), astr()], [muCon("
"[1..-1]), translateToIString(expression), translateProtocolTail(tail)], p.src);
 
 private MuExp  translateProtocolTail(p: (ProtocolTail) `  `) =
-   muPrim("add", astr(), [astr(), astr(), astr()], [muCon(""[1..-1]), translateToIString(expression), translateProtocolTail(tail)], p@\loc);
+   muPrim("add", astr(), [astr(), astr(), astr()], [muCon(""[1..-1]), translateToIString(expression), translateProtocolTail(tail)], p.src);
 
 private MuExp translateProtocolTail((ProtocolTail) ``) = muCon(""[1 ..]);
 
 private MuExp translatePathPart((PathPart) ``) = muCon(""[..-1]);
 
 private MuExp translatePathPart(p: (PathPart) `  `) =
-   muPrim("add", astr(), [astr(), astr(), astr()], [ muCon("
"[..-1]), translateToIString(expression), translatePathTail(tail)], p@\loc);
+   muPrim("add", astr(), [astr(), astr(), astr()], [ muCon("
"[..-1]), translateToIString(expression), translatePathTail(tail)], p.src);
 
 private MuExp translatePathTail(p: (PathTail) `  `) =
-   muPrim("add", astr(), [astr(), astr(), astr()], [ muCon(""[1..-1]), translateToIString(expression), translatePathTail(tail)], p@\loc);
+   muPrim("add", astr(), [astr(), astr(), astr()], [ muCon(""[1..-1]), translateToIString(expression), translatePathTail(tail)], p.src);
 
 private MuExp translatePathTail((PathTail) ``) = muCon(""[1..-1]);
 
@@ -463,7 +463,7 @@ default MuExp translateLiteral((Literal) ``) {
     try {
         return muCon(readTextValueString(""));
     } catch e: {
-        throw CompileTimeError(error("", s@\loc));
+        throw CompileTimeError(error("", s.src));
     }
 }
 
@@ -489,7 +489,7 @@ MuExp translate(e:appl(prod(Symbol::label("parsed",Symbol::lex("Concrete")), [_]
 
 // this detects that a parse error has occurred earlier and we generate an exception here:
 MuExp translate(e:appl(prod(label("typed",lex("Concrete")), [_],_),_))
-  = muValueBlock(avalue(), [muThrow(muCon("(compile-time) parse error in concrete syntax"), e@\loc)]);
+  = muValueBlock(avalue(), [muThrow(muCon("(compile-time) parse error in concrete syntax"), e.src)]);
 
 // these three constant parts of trees are directly mapped to constants:
 private MuExp translateConcreteExpression(t:appl(prod(lit(_),_, _), _)) = muCon(t);
@@ -500,29 +500,29 @@ private MuExp translateConcreteExpression(t:appl(prod(layouts(_),_, _), _)) = mu
 private MuExp translateConcreteExpression(t:appl(prod(Symbol::label("$MetaHole", Symbol _),[_], _), [ConcreteHole hole])) {
      = getVariableScope("", getConcreteHoleVarLoc(t));
 
-    return mkVar(unescape(""), hole.name@\loc);
+    return mkVar(unescape(""), hole.name.src);
     //return muVar("", fuid, pos, getType(hole.symbol@\loc));
 }
 
 // Four cases of lists are detected to be able to implement splicing
 // splicing is different for separated lists from normal lists
 private MuExp translateConcreteExpression(t:appl(p:Production::regular(s:Symbol::iter(Symbol elem)), list[Tree] args))
-  = muTreeAppl(muCon(p), translateConcreteExpressionList(elem, args, t@\loc), t@\loc);
+  = muTreeAppl(muCon(p), translateConcreteExpressionList(elem, args, t.src), t.src);
 
 private MuExp translateConcreteExpression(t:appl(p:Production::regular(s:Symbol::\iter-star(Symbol elem)), list[Tree] args))
-  = muTreeAppl(muCon(p), translateConcreteExpressionList(elem, args, t@\loc), t@\loc);
+  = muTreeAppl(muCon(p), translateConcreteExpressionList(elem, args, t.src), t.src);
 
 private MuExp translateConcreteExpression(t:appl(p:Production::regular(s:Symbol::\iter-seps(Symbol elem, list[Symbol] seps)), list[Tree] args))
-  = muTreeAppl(muCon(p), translateConcreteExpressionSeparatedList(elem, seps, args, t@\loc), t@\loc);
+  = muTreeAppl(muCon(p), translateConcreteExpressionSeparatedList(elem, seps, args, t.src), t.src);
 
 private MuExp translateConcreteExpression(t:appl(p:Production::regular(s:Symbol::\iter-star-seps(Symbol elem, list[Symbol] seps)), list[Tree] args))
-  = muTreeAppl(muCon(p), translateConcreteExpressionSeparatedList(elem, seps, args, t@\loc), t@\loc);
+  = muTreeAppl(muCon(p), translateConcreteExpressionSeparatedList(elem, seps, args, t.src), t.src);
 
 private MuExp translateConcreteExpression(char(int i)) =  muTreeChar(i);
 
 // this is a normal parse tree node:
 private default MuExp translateConcreteExpression(t:appl(Production p, list[Tree] args))
-  = muTreeAppl(muCon(p), [translateConcreteExpression(a) | a <- args], (t@\loc?) ? t@\loc : |unknown:///|); // TODO: t@\loc does not work here, why?????
+  = muTreeAppl(muCon(p), [translateConcreteExpression(a) | a <- args], (t.src?) ? t.src : |unknown:///|); // TODO: t@\loc does not work here, why?????
 
 
 bool isListPlusVar(Symbol elem, appl(prod(label("$MetaHole", _),[sort("ConcreteHole")], {\tag("holeType"(Symbol::\iter(elem)))}), [_])) = true;
@@ -599,13 +599,13 @@ private MuExp translateConcreteExpressionSeparatedList(Symbol eltType, list[Symb
 
       // first we splice or add the first element:
       if (isListVar(eltType, first)) {
-        code += [muPrim("splice_list", avoid(), [avalue(), treeType], [writer, muTreeGetArgs(varExp)], first@\loc?|unknown:///|)];
+        code += [muPrim("splice_list", avoid(), [avalue(), treeType], [writer, muTreeGetArgs(varExp)], first.src)];
       }
       else {
-        code += [muPrim("add_list_writer", avoid(), [avalue(), treeType], [writer, varExp], first@\loc?|unknown:///|)];
+        code += [muPrim("add_list_writer", avoid(), [avalue(), treeType], [writer, varExp], first.src)];
       }
 
-      sepCode    = [muPrim("add_list_writer", avoid(), [avalue(), treeType], [writer, muCon(e)], e@\loc?|unknown:///|) | e <- sepTrees];
+      sepCode    = [muPrim("add_list_writer", avoid(), [avalue(), treeType], [writer, muCon(e)], e.src) | e <- sepTrees];
       secondVarExp = translateConcreteExpression(second);
 
       // then separators are optionally added:
@@ -638,10 +638,10 @@ private MuExp translateConcreteExpressionSeparatedList(Symbol eltType, list[Symb
       if (more == []) {
         // the last element must be printed, or sliced now:
         if (isListVar(eltType, second)) {
-          code += [muPrim("splice_list", avoid(), [avalue(), treeType], [writer, muTreeGetArgs(secondVarExp)], second@\loc?|unknown:///|)];
+          code += [muPrim("splice_list", avoid(), [avalue(), treeType], [writer, muTreeGetArgs(secondVarExp)], second.src)];
         }
         else {
-          code += [muPrim("add_list_writer", avoid(), [avalue(), treeType], [writer, secondVarExp], second@\loc?|unknown:///|)];
+          code += [muPrim("add_list_writer", avoid(), [avalue(), treeType], [writer, secondVarExp], second.src)];
         }
       }
       elems = [second, *more];
@@ -684,11 +684,11 @@ MuExp translate (e:(Expression) ` {  {  ..  ]`) {
 
   return
     muValueBlock(resultType,
-                 [ muConInit(writer, muPrim("open_list_writer", avalue(), [], [], e@\loc)),
-                   muForRange("", elem, translate(first), muCon(0), translate(last), muPrim("add_list_writer", avoid(), [resultType, elemType], [writer, elem], e@\loc), muBlock([])),
-                   muPrim("close_list_writer", resultType, [avalue()], [writer], e@\loc)
+                 [ muConInit(writer, muPrim("open_list_writer", avalue(), [], [], e.src)),
+                   muForRange("", elem, translate(first), muCon(0), translate(last), muPrim("add_list_writer", avoid(), [resultType, elemType], [writer, elem], e.src), muBlock([])),
+                   muPrim("close_list_writer", resultType, [avalue()], [writer], e.src)
                  ]);
 }
 
@@ -756,9 +756,9 @@ MuExp translate (e:(Expression) `[  ,  .. <
 
   return
     muValueBlock(getType(e),
-                 [ muConInit(writer, muPrim("open_list_writer", alist(elemType), [], [], e@\loc)),
-                   muForRange("", elem, translate(first), translate(second), translate(last), muPrim("add_list_writer", avoid(), [elemType], [writer, elem], e@\loc), muBlock([])),
-                   muPrim("close_list_writer", avoid(), [avalue()], [writer], e@\loc)
+                 [ muConInit(writer, muPrim("open_list_writer", alist(elemType), [], [], e.src)),
+                   muForRange("", elem, translate(first), translate(second), translate(last), muPrim("add_list_writer", avoid(), [elemType], [writer, elem], e.src), muBlock([])),
+                   muPrim("close_list_writer", avoid(), [avalue()], [writer], e.src)
                  ]);
 }
 
@@ -891,7 +891,7 @@ private MuExp translateReducer(Expression e){
 // -- reified type expression ---------------------------------------
 
 MuExp translate (e:(Expression) `type (  , )`) {
-    return muPrim("create_reifiedType", avalue(), [avalue(), avalue()], [translate(symbol), translate(definitions)], e@\loc);
+    return muPrim("create_reifiedType", avalue(), [avalue(), avalue()], [translate(symbol), translate(definitions)], e.src);
 }
 
 // -- call expression -----------------------------------------------
@@ -903,14 +903,14 @@ MuExp translate(e:(Expression) ` ( <{Expression ","}* arg
    list[MuExp] args = [ translate(a) | Expression a <- arguments ];
    exp_type = getOuterType(expression);
    if(exp_type == "astr"){
-   		return muPrim("create_node", getType(e), [ getType(arg) | arg <- arguments ], [receiver, *args, muKwpActuals(kwargs)], e@\loc);
+   		return muPrim("create_node", getType(e), [ getType(arg) | arg <- arguments ], [receiver, *args, muKwpActuals(kwargs)], e.src);
    }
 
    if(exp_type == "aloc"){
        if(size(args) == 2){
-            return muPrim("create_loc_with_offset", aloc(), [aloc(), aint(), aint()], [receiver, *args], e@\loc);
+            return muPrim("create_loc_with_offset", aloc(), [aloc(), aint(), aint()], [receiver, *args], e.src);
        } else {
-         return muPrim("create_loc_with_offset_and_begin_end", aloc(), [aloc(),aint(), aint(), atuple(atypeList([aint(), aint()])), atuple(atypeList([aint(), aint()]))], [receiver, *args], e@\loc);
+         return muPrim("create_loc_with_offset_and_begin_end", aloc(), [aloc(),aint(), aint(), atuple(atypeList([aint(), aint()])), atuple(atypeList([aint(), aint()]))], [receiver, *args], e.src);
        }
    }
    str fname = unescape("");
@@ -921,7 +921,7 @@ MuExp translate(e:(Expression) ` ( <{Expression ","}* arg
    		}
    		catch "NotConstant":  /* not a constant, generate an ordinary call instead */;
    }
-   return muOCall(receiver, ftype, args, kwargs, e@\loc);
+   return muOCall(receiver, ftype, args, kwargs, e.src);
 }
 
 private lrel[str,MuExp] translateKeywordArguments((KeywordArguments[Expression]) ``) {
@@ -1075,9 +1075,9 @@ private list[MuExp] translateComprehensionContribution(str kind, AType resultTyp
   return
 	  for( r <- results){
 	    if((Expression) `* ` := r){
-	       append muPrim("splice_", resultType, [avalue(), getType(r)], [writer, translate(exp)], exp@\loc);
+	       append muPrim("splice_", resultType, [avalue(), getType(r)], [writer, translate(exp)], exp.src);
 	    } else {
-	      append muPrim("add__writer", resultType, [avalue(), getType(r)], [writer, translate(r)], r@\loc);
+	      append muPrim("add__writer", resultType, [avalue(), getType(r)], [writer, translate(r)], r.src);
 	    }
 	  }
 }
@@ -1092,9 +1092,9 @@ private MuExp translateComprehension(c: (Comprehension) `[ <{Expression ","}+ re
     //iprintln(btscopes);
     return
         muValueBlock(resultType,
-                     [ muConInit(writer, muPrim("open_list_writer", avalue(), [], [], c@\loc)),
+                     [ muConInit(writer, muPrim("open_list_writer", avalue(), [], [], c.src)),
                        translateAndConds(btscopes, conds, muBlock(translateComprehensionContribution("list", resultType, writer, [r | r <- results])), muBlock([])),
-                       muPrim("close_list_writer", getType(c), [avalue()], [writer], c@\loc)
+                       muPrim("close_list_writer", getType(c), [avalue()], [writer], c.src)
                      ]);
 }
 
@@ -1108,9 +1108,9 @@ private MuExp translateComprehension(c: (Comprehension) `{ <{Expression ","}+ re
     //iprintln(btscopes);
     return
         muValueBlock(resultType,
-                     [ muConInit(writer, muPrim("open_set_writer", avalue(), [], [], c@\loc)),
+                     [ muConInit(writer, muPrim("open_set_writer", avalue(), [], [], c.src)),
                       translateAndConds(btscopes, conds, muBlock(translateComprehensionContribution("set", resultType, writer, [r | r <- results])), muBlock([])),
-                      muPrim("close_set_writer", getType(c), [avalue()], [writer], c@\loc)
+                      muPrim("close_set_writer", getType(c), [avalue()], [writer], c.src)
                     ]);
 }
 
@@ -1123,9 +1123,9 @@ private MuExp translateComprehension(c: (Comprehension) `( : _writer", avalue(), [], [], e@\loc);
+       kindwriter_open_code = muPrim("open__writer", avalue(), [], [], e.src);
 
        enterWriter(writer.name);
        code = [ muConInit(writer, kindwriter_open_code) ];
        for(elem <- es){
            if(elem is splice){
-              code += muPrim("splice_", avoid(), [avalue(), getType(elem)], [writer, translate(elem.argument)], elem.argument@\loc);
+              code += muPrim("splice_", avoid(), [avalue(), getType(elem)], [writer, translate(elem.argument)], elem.argument.src);
             } else {
-              code += muPrim("add__writer", avoid(), [avalue(), elmType], [writer, translate(elem)], elem@\loc);
+              code += muPrim("add__writer", avoid(), [avalue(), elmType], [writer, translate(elem)], elem.src);
            }
        }
-       code += [ muPrim("close__writer", getType(e), [avalue()], [ writer ], e@\loc) ];
+       code += [ muPrim("close__writer", getType(e), [avalue()], [ writer ], e.src) ];
        leaveWriter();
        return muValueBlock(getType(e), code);
     } else {
       //if(size(es) == 0 || all(elm <- es, isConstant(elm))){
       //   return kind == "list" ? muCon([getConstantValue(elm) | elm <- es]) : muCon({getConstantValue(elm) | elm <- es});
       //} else
-        return muPrim("create_", getType(e), [elmType], [ translate(elem) | Expression elem <- es ], e@\loc);
+        return muPrim("create_", getType(e), [elmType], [ translate(elem) | Expression elem <- es ], e.src);
     }
 }
 
@@ -1188,7 +1188,7 @@ MuExp translate (e:(Expression) `\< <{Expression ","}+ elements> \>`) {
     //if(isConstant(e)){
     //  return muCon(readTextValueString(""));
     //} else
-        return muPrim("create_tuple", getType(e), [ getType(elem) | Expression elem <- elements], [ translate(elem) | Expression elem <- elements ], e@\loc);
+        return muPrim("create_tuple", getType(e), [ getType(elem) | Expression elem <- elements], [ translate(elem) | Expression elem <- elements ], e.src);
 }
 
 // -- map expression ------------------------------------------------
@@ -1198,7 +1198,7 @@ MuExp translate (e:(Expression) `( <{Mapping[Expression] ","}* mappings> )`) {
    //  return muCon(readTextValueString(""));
    //} else
    mapType = getType(e);
-   return muPrim("create_map", mapType, [mapType.keyType, mapType.valType], [ translate(m.from), translate(m.to) | m <- mappings ], e@\loc);
+   return muPrim("create_map", mapType, [mapType.keyType, mapType.valType], [ translate(m.from), translate(m.to) | m <- mappings ], e.src);
 }
 
 // -- it expression (in reducer) ------------------------------------
@@ -1218,15 +1218,15 @@ MuExp translateBool((Expression) ``, BTSCOPES btscopes, MuExp t
     translateBool(v, btscopes, trueCont, falseCont);
 
 MuExp translate((QualifiedName) ``) =
-    mkVar(prettyPrintName(v), v@\loc);
+    mkVar(prettyPrintName(v), v.src);
 
 MuExp translateBool((QualifiedName) ``, BTSCOPES _btscopes, MuExp trueCont, MuExp falseCont) =
-    muIfExp(mkVar(prettyPrintName(v), v@\loc), trueCont, falseCont);
+    muIfExp(mkVar(prettyPrintName(v), v.src), trueCont, falseCont);
 
 // For the benefit of names in regular expressions
 
 MuExp translate((Name) ``) =
-    mkVar(unescape(""), name@\loc);
+    mkVar(unescape(""), name.src);
 
 // -- subscript expression ------------------------------------------
 // Comes in 2 flavours:
@@ -1240,7 +1240,7 @@ MuExp translate(Expression e:(Expression) ` [ <{Expression ","}+
 private MuExp translateSubscript(Expression e:(Expression) ` [ <{Expression ","}+ subscripts> ]`, bool isGuarded){
    op = isGuarded ? "guarded_subscript" : "subscript";
    access = muPrim(op, avalue() /*getType(e)*/, getType(exp) + [getType(s) | s <- subscripts],
-                       translate(exp) + [isWildCard("") ? muCon("_") : translate(s) | Expression s <- subscripts], e@\loc);
+                       translate(exp) + [isWildCard("") ? muCon("_") : translate(s) | Expression s <- subscripts], e.src);
 
    return access;
 }
@@ -1261,7 +1261,7 @@ MuExp translate ((Expression) ` [  . `) {
    ufield = unescape("");
 
    if(isTupleAType(tp) || isRelAType(tp) || isListRelAType(tp) || isMapAType(tp)) {
-       return translateProject(e, expression, [(Field)``], e@\loc, false);
+       return translateProject(e, expression, [(Field)``], e.src, false);
    }
 
    if(isADTAType(tp)){
@@ -1333,7 +1333,7 @@ MuExp translate ((Expression) ` [  =  \< <{Field ","}+ fields> \>`) =
-  translateProject(e, expression, [f | f <- fields], e@\loc, false);
+  translateProject(e, expression, [f | f <- fields], e.src, false);
 
 MuExp translateProject(Expression e, Expression base, list[Field] fields, loc src, bool isGuarded){
     tp = getType(base);
@@ -1413,7 +1413,7 @@ MuExp translate (e:(Expression) `@`) {
 // -- is expression --------------------------------------------------
 
 MuExp translate (e:(Expression) ` is `) =
-    muPrim("is", abool(), [getType(expression)], [translate(expression), muCon(unescape(""))], e@\loc);
+    muPrim("is", abool(), [getType(expression)], [translate(expression), muCon(unescape(""))], e.src);
 
 MuExp translateBool(e:(Expression) ` is `, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont)
     = muIfExp(translate(e),  trueCont, falseCont);
@@ -1490,7 +1490,7 @@ MuExp translateGuarded(exp: (Expression) ` [ <{Expression ","}+
     = translateSubscript(exp, true);
 
 MuExp translateGuarded(exp: (Expression) ` \< <{Field ","}+ fields> \>`)
-    = translateProject(exp, expression, [f | f <- fields], exp@\loc, true);
+    = translateProject(exp, expression, [f | f <- fields], exp.src, true);
 
 MuExp translateGuarded(exp: (Expression) `@`){
    tp = getType(expression);
@@ -1503,11 +1503,11 @@ MuExp translateGuarded(exp: (Expression) `@`){
 }
 
 MuExp translateGuarded(exp: (Expression) ` . `)
-    = translateProject(exp, expression, [(Field)``], exp@\loc, true);
+    = translateProject(exp, expression, [(Field)``], exp.src, true);
     //= muGuardedGetField(getType(exp), getType(expression), translate(expression),  unescape(""));
 
 MuExp translateGuarded(exp: (Expression) ``)
-    = muIsVarKwpDefined(mkVar("", name@\loc));
+    = muIsVarKwpDefined(mkVar("", name.src));
 
 
 // -- isDefinedOtherwise expression ---------------------------------
@@ -1522,7 +1522,7 @@ MuExp translate(e: (Expression) ` ? `) {
 }
 
 MuExp translateBool(e:(Expression) ` ? `, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont)
-    = translateIfDefinedOtherwise(muBlock([translate(lhs), trueCont]), muBlock([translate(rhs), falseCont]), e@\loc);
+    = translateIfDefinedOtherwise(muBlock([translate(lhs), trueCont]), muBlock([translate(rhs), falseCont]), e.src);
 
 
 public MuExp translateIfDefinedOtherwise(MuExp muLHS, MuExp muRHS, loc _src) {
@@ -1632,7 +1632,7 @@ MuExp translate(e:(Expression) `-`)
 // -- splice expression ---------------------------------------------
 
 MuExp translate(e:(Expression) `*`) {
-    throw "Splice `` cannot occur outside set or list at ";
+    throw "Splice `` cannot occur outside set or list at ";
 }
 
 // -- asType expression ---------------------------------------------
@@ -1643,9 +1643,9 @@ MuExp translate(e:(Expression) `[  ] `)  {
                                 [ avalue(), astr(), aloc()],
                                 [ muATypeCon(resultType, collectNeededDefs(resultType)),
    					              translate(argument),
-   					              muCon(argument@\loc)
+   					              muCon(argument.src)
    					            ],
-   					            argument@\loc);
+   					            argument.src);
 }
 
 // -- composition expression ----------------------------------------
@@ -2291,7 +2291,7 @@ MuExp translate(e:(Expression) ` \<==\> `, BTSCO
         return muValueBlock(abool(), [ muConInit(rhs_val, translate(rhs)),
                                        muIfExp(translate(lhs),
                                                rhs_val,
-                                               muPrim("not", abool(), [abool()], [rhs_val], e@\loc))
+                                               muPrim("not", abool(), [abool()], [rhs_val], e.src))
                                      ]);
    }
 
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc
index 207ebe134fc..01cb0aa9f79 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc
@@ -80,9 +80,9 @@ tuple[TModel, MuModule] r2mu(lang::rascal::\syntax::Rascal::Module M, TModel tmo
       mtags = translateTags(M.header.tags);
       setModuleTags(mtags);
       if(hasIgnoreCompilerTag(mtags)){
-            e = info("Ignore tag suppressed compilation", M.header.name@\loc);
+            e = info("Ignore tag suppressed compilation", M.header.name.src);
             tmodel.messages += [e];
-            return ;
+            return ;
       }
      
       //if(verbose) println("r2mu: entering ... , enableAsserts: ");
@@ -115,7 +115,7 @@ tuple[TModel, MuModule] r2mu(lang::rascal::\syntax::Rascal::Module M, TModel tmo
    	  				  getVariableInitializationsInModule(),   
    	  				  getCommonKeywordFieldsNameAndType(),
    	  				  getGrammar(),
-   	  				  M@\loc) /*,   
+   	  				  M.src) /*,   
    	  				  reloc,
    	  				  pcfg.srcs)*/
    	  	      >;
@@ -125,11 +125,11 @@ tuple[TModel, MuModule] r2mu(lang::rascal::\syntax::Rascal::Module M, TModel tmo
         if (compilerConfig.verbose) { println("Parse error in concrete syntax ; returning error module"); }
         msg = error("Parse error in concrete syntax fragment", l);
         tmodel.messages += [msg];
-        return ;
+        return ;
    }
    catch CompileTimeError(Message m): {
         tmodel.messages += [m];
-        return ;
+        return ;
    }
    //catch value e: {
    //     return ", M@\loc)}, M@\loc)>;
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc
index 76d20620cb7..c7304fdcd44 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc
@@ -262,7 +262,7 @@ MuExp translateLitPat(Literal lit, AType _subjectType, MuExp subject, BTSCOPES _
 MuExp translatePat(p:(Pattern) `-`, AType subjectType, MuExp subject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, bool subjectAssigned=false, MuExp restore = muBlock([])) {
     if(pat is literal){
         if(Literal lit := pat.literal && (lit is integer || lit is \real || lit is \rational)){
-            code = muPrim("negative", getType(pat), [getType(lit)], [translate(lit)], p@\loc);
+            code = muPrim("negative", getType(pat), [getType(lit)], [translate(lit)], p.src);
             return muIfElse(muEqual(code, subject), trueCont, falseCont);
         }
     }
@@ -383,7 +383,7 @@ tuple[MuExp exp, list[MuExp] vars] processRegExpLiteral(e: (RegExpLiteral) `/:\>`: {
@@ -408,9 +408,9 @@ tuple[MuExp exp, list[MuExp] vars] processRegExpLiteral(e: (RegExpLiteral) `/; 
    }  
 }
@@ -439,7 +439,7 @@ tuple[MuExp var, list[MuExp] exps] extractNamedRegExp((RegExp) `\<: = getVariableScope("", name@\loc);
+    = getVariableScope("", name.src);
    return ", fuid, pos, astr(), patternVariableId()), exps>;
 }
 
@@ -539,7 +539,7 @@ MuExp translateConcretePattern(e:appl(prod(Symbol::label("parsed",Symbol::lex("C
 // Concrete pattern was not parsed correctly  
 MuExp translateConcretePattern(e:appl(prod(Symbol::label("typed",Symbol::lex("Concrete")), [_],_),[Tree concrete]), 
                    AType _, MuExp subject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, MuExp restore = muBlock([])) 
-  = muValueBlock(avalue(),[muThrow(muCon("(compile-time) parse error in concrete syntax"), e@\loc)]);   
+  = muValueBlock(avalue(),[muThrow(muCon("(compile-time) parse error in concrete syntax"), e.src)]);   
 
 // Parsed Concrete pattern
 
@@ -561,7 +561,7 @@ MuExp translateParsedConcretePattern(appl(prod(Symbol::layouts(_),_,_), _), ATyp
 MuExp translateParsedConcretePattern(appl(prod(Symbol::label("$MetaHole", Symbol _),[Symbol::sort("ConcreteHole")], {\tag("holeType"(Symbol holeType))}), [ConcreteHole hole]),
                         AType patType, AType subjectType, MuExp subjectExp, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, MuExp restore = muBlock([])) {
    holeName = prettyPrintName(hole.name);
-   return isWildCard(holeName) ? trueCont :  muBlock([muVarInit(mkVar(holeName, hole.name@\loc), subjectExp), trueCont]);
+   return isWildCard(holeName) ? trueCont :  muBlock([muVarInit(mkVar(holeName, hole.name.src), subjectExp), trueCont]);
 }
 
 // ---- char
@@ -668,13 +668,13 @@ Symbol getConcreteHoleSymbol(appl(Production::prod(Symbol::label("$MetaHole", Sy
     
 loc getConcreteHoleVarLoc(h: appl(Production _prod, list[Tree] args)) {
 	//println("getConcreteHoleVarLoc: ");
-	if(args[0].args[4].args[0]@\loc?){
+	if(args[0].args[4].args[0].src?){
 	    //iprintln(args[0].args[4].args[0]);
-		return args[0].args[4].args[0]@\loc;
+		return args[0].args[4].args[0].src;
 	}
-	if(args[0].args[4]@\loc?){
+	if(args[0].args[4].src?){
 		println("getConcreteHoleVarLoc: moved up one level to get loc: ");
-		return args[0].args[4]@\loc;
+		return args[0].args[4].src;
 	}
 	println("getConcreteHoleVarLoc: Missing loc:");
 	iprintln(h);
@@ -1008,8 +1008,8 @@ MuExp translatePat(p:(Pattern) ``, AType subjectType, MuExp
    if(isWildCard("")){
       return trueCont;
    }
-   var = mkVar(prettyPrintName(name), name@\loc);
-   if(isDefinition(name@\loc) && !subjectAssigned){
+   var = mkVar(prettyPrintName(name), name.src);
+   if(isDefinition(name.src) && !subjectAssigned){
      //return inlineVar(var, subjectExp, trueCont);
      //return muValueBlock(abool(), [muVarDecl(var), inlineVar(var, subjectExp, trueCont)]);
      //return muValueBlock(abool(), [muVarInit(var, subjectExp), trueCont]);
@@ -1043,7 +1043,7 @@ MuExp translatePat(p:(Pattern) ` `, AType subjectType, MuExp
     	      return trueCont;
     	   }
     	   ppname = prettyPrintName(name);
-    	    = getVariableScope(ppname, name@\loc);
+    	    = getVariableScope(ppname, name.src);
     	   var = muVar(prettyPrintName(name), fuid, pos, trType[alabel=ppname], patternVariableId());
     	   if(isSameVar(var, subjectExp)){
     	       return trueCont;
@@ -1059,7 +1059,7 @@ MuExp translatePat(p:(Pattern) ` `, AType subjectType, MuExp
           return muIfElse(precond, trueCont, falseCont);
        }
        ppname = prettyPrintName(name);
-        = getVariableScope(ppname, name@\loc);
+        = getVariableScope(ppname, name.src);
        var = muVar(prettyPrintName(name), fuid, pos, trType[alabel=ppname], patternVariableId());
        if(isSameVar(var, subjectExp)){
             return muIfElse(precond, trueCont, falseCont);
@@ -1090,7 +1090,7 @@ MuExp translatePat(p:(Pattern) ` `, AType subjectType, MuExp
                 return muIfElse(precond, trueCont, falseCont);
             }
             ppname = prettyPrintName(name);
-             = getVariableScope(ppname, name@\loc);
+             = getVariableScope(ppname, name.src);
             var = muVar(prettyPrintName(name), fuid, pos, trType[alabel=ppname], patternVariableId());
             if(isSameVar(var, subjectExp)){
                 return muIfElse(precond, trueCont, falseCont);
@@ -1161,7 +1161,7 @@ MuExp translatePat(p:(Pattern) ` ( <{Pattern ","}* arguments
        MuExp arg_fail = computeFail(p, lpats, i-1, btscopes, falseCont);
       
        MuExp arg = nonterminal_get_arg
-                 ? muPrim("nonterminal-get-arg", avalue(), [subjectType, aint()], [subject, muCon(i)], lpats[i]@\loc)
+                 ? muPrim("nonterminal-get-arg", avalue(), [subjectType, aint()], [subject, muCon(i)], lpats[i].src)
                  : muSubscript(subject, subjectType, muCon(i))
                  ;
  
@@ -1271,7 +1271,7 @@ BTINFO getBTInfoSet(p:(Pattern) ``, BTSCOPE btscope, BTSCOPE
 }  
 
 MuExp translatePatAsSetElem(p:(Pattern) ``, bool last, AType elmType, MuExp subject, MuExp prevSubject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont/*, MuExp restore=muBlock([])*/) {
-    return translateVarAsSetElem(mkVar(p), isDefinition(p), p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont/*, restore=restore*/);
+    return translateVarAsSetElem(mkVar(p), isDefinition(p), p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont/*, restore=restore*/);
 }
 
 BTINFO getBTInfoSet(p:(Pattern) ` `, BTSCOPE btscope, BTSCOPES btscopes) {
@@ -1282,7 +1282,7 @@ BTINFO getBTInfoSet(p:(Pattern) ` `, BTSCOPE btscope, BTSCOP
 }
 
 MuExp translatePatAsSetElem(p:(Pattern) ` `, bool last, AType elmType, MuExp subject, MuExp prevSubject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont/*, MuExp restore=muBlock([])*/) {
-    return translateVarAsSetElem(mkVar(p), isDefinition(p), p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont/*, restore=restore*/);
+    return translateVarAsSetElem(mkVar(p), isDefinition(p), p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont/*, restore=restore*/);
 }
 
 MuExp translateVarAsSetElem(MuExp var, bool isDefinition, loc patloc, bool last, AType elmType, MuExp subject, MuExp prevSubject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont/*, MuExp restore=muBlock([])*/) {
@@ -1360,16 +1360,16 @@ BTINFO getBTInfoSet(p:(Pattern) `*`, BTSCOPE btscope, BTSCOPES btscop
 
 MuExp translatePatAsSetElem(p:(Pattern) `*`, bool last, AType elmType, MuExp subject, MuExp prevSubject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont) {
     if("" == "_"){
-        return translateMultiVarAsSetElem(mkVar(p), false, p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
+        return translateMultiVarAsSetElem(mkVar(p), false, p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
     }
-    return translateMultiVarAsSetElem(mkVar(p), isDefinition(name@\loc), p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);  
+    return translateMultiVarAsSetElem(mkVar(p), isDefinition(name.src), p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);  
 }
 
 MuExp translatePatAsSetElem(p:(Pattern) `*`, bool last, AType elmType, MuExp subject, MuExp prevSubject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont) {
     if("" == "_"){
-        return translateMultiVarAsSetElem(mkVar(p), false, p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
+        return translateMultiVarAsSetElem(mkVar(p), false, p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
     }
-    return translateMultiVarAsSetElem(mkVar(p), isDefinition(name@\loc), p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont); 
+    return translateMultiVarAsSetElem(mkVar(p), isDefinition(name.src), p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont); 
 }
  
 BTINFO getBTInfoSet(p:(Pattern) `* `, BTSCOPE btscope, BTSCOPES btscopes) {
@@ -1385,10 +1385,10 @@ BTINFO getBTInfoSet(p:(Pattern) `* `, BTSCOPE btscope, BTSCO
 
 MuExp translatePatAsSetElem(p:(Pattern) `* `, bool last, AType elmType, MuExp subject, MuExp prevSubject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont) {
    if("" == "_"){
-    return translateMultiVarAsSetElem(mkVar(p), false, p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
+    return translateMultiVarAsSetElem(mkVar(p), false, p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
    }
    
-   return translateMultiVarAsSetElem(mkVar(p), true, p@\loc, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
+   return translateMultiVarAsSetElem(mkVar(p), true, p.src, last, elmType, subject, prevSubject, btscopes, trueCont, falseCont);
 }
 
 MuExp translateMultiVarAsSetElem(MuExp var, bool isDefinition, loc patsrc, bool _last, AType elmType, MuExp subject, MuExp prevSubject, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont) {
@@ -1486,7 +1486,7 @@ MuExp translatePatAsSetElem(p:(Pattern) ` : `, bool
     forAll_scope = my_btscope.enter+ "_NAMED_SET_ELM";
     code = muForAll(forAll_scope, elem, aset(elmType), prevSubject,
                     translatePat(p, elmType, elem, btscopes, 
-                        muBlock([ muConInit(subject, muPrim("delete", aset(elmType), [aset(elmType), elmType], [prevSubject, elem], p@\loc)),
+                        muBlock([ muConInit(subject, muPrim("delete", aset(elmType), [aset(elmType), elmType], [prevSubject, elem], p.src)),
                                   asgVar
                                 ]),            
                         muFail(forAll_scope)
@@ -1529,7 +1529,7 @@ MuExp translatePatAsSetElem(p:(Pattern) `  : ")|| isDefinition(pat.qualifiedName@\loc); 
+    return isWildCard("")|| isDefinition(pat.qualifiedName.src); 
   } else if(pat is qualifiedName){
-    return isWildCard("") || isDefinition(pat.qualifiedName@\loc);  
+    return isWildCard("") || isDefinition(pat.qualifiedName.src);  
   } else if(pat is typedVariable){
     return true;
   } else 
@@ -1623,7 +1623,7 @@ private bool isDefinition(Pattern pat){
 private bool isDefinedOutsidePat(loc def, Pattern container){
     try {
         defined = getDefinition(def); 
-        return !isContainedIn(defined, container@\loc);     // TODO: adapt
+        return !isContainedIn(defined, container.src);     // TODO: adapt
     } catch: {
          return false;
     }
@@ -1634,17 +1634,17 @@ private bool allVarsDefinedOutsidePat(Pattern pat, Pattern container){
      return allVarsDefinedOutsidePat(pat.argument, container);
   } else if(pat is multiVariable){
         if(isWildCard("")) return false;
-        return isDefinedOutsidePat(pat.qualifiedName@\loc, container);
+        return isDefinedOutsidePat(pat.qualifiedName.src, container);
   } else if(pat is qualifiedName){
         if(isWildCard("")) return false;
-        return isDefinedOutsidePat(pat.qualifiedName@\loc, container);  
+        return isDefinedOutsidePat(pat.qualifiedName.src, container);  
   } else if(pat is typedVariable){
     return false;
   } else {
     bool found = true;
     visit(pat){
-        case (Pattern) ``:  found = found && isDefinedOutsidePat(qualifiedName@\loc, container);
-        case (Pattern) `*`: found = found && isDefinedOutsidePat(qualifiedName@\loc, container);
+        case (Pattern) ``:  found = found && isDefinedOutsidePat(qualifiedName.src, container);
+        case (Pattern) `*`: found = found && isDefinedOutsidePat(qualifiedName.src, container);
     }
     return found;
     }
@@ -1658,31 +1658,31 @@ private MuExp mkVar(Pattern pat){
         if(isWildCard("")){
             return muVar("", topFunctionScope(), -1, avalue(), patternVariableId());
         } else {
-            return mkVar("", pat.qualifiedName@\loc);
+            return mkVar("", pat.qualifiedName.src);
         }
   } else if(pat is qualifiedName){
         if(isWildCard("")){
              return muVar("", topFunctionScope(), -1, avalue(), patternVariableId());
         } else {
-            return mkVar("", pat@\loc);
+            return mkVar("", pat.src);
         }
   } else if(pat is typedVariable){
         if(isWildCard("")){
              return muVar("", topFunctionScope(), -1, getType(pat.name), patternVariableId());
          } else {
-            return mkVar("", pat.name@\loc);
+            return mkVar("", pat.name.src);
          }
   } else if(pat is variableBecomes){
         if(isWildCard("")){
              return muVar("", topFunctionScope(), -1, avalue(), patternVariableId());
         } else {
-            return mkVar("", pat.name@\loc);
+            return mkVar("", pat.name.src);
         }
   } else if(pat is typedVariableBecomes){
         if(isWildCard("")){
             return muVar("", topFunctionScope(), -1, getType(pat.name), patternVariableId());
         } else {
-            return mkVar("", pat.name@\loc);
+            return mkVar("", pat.name.src);
         }
   } else
     throw "mkVar: ";
@@ -1789,12 +1789,12 @@ MuExp translateSetPat(p:(Pattern) `{<{Pattern ","}* _>}`, AType subjectType, MuE
    MuExp fixedParts = muCon({con | muCon(value con) <- fixedLiterals });
     
    for(vp <- fixedVars){
-       fixedParts = muPrim("add", aset(elmType), [aset(elmType), elmType], [fixedParts, mkVar(vp)], p@\loc);
+       fixedParts = muPrim("add", aset(elmType), [aset(elmType), elmType], [fixedParts, mkVar(vp)], p.src);
    }
    for(vp <- fixedMultiVars){
-       fixedParts = muPrim("add", aset(elmType), [aset(elmType), aset(elmType)], [fixedParts, mkVar(vp)], p@\loc);
+       fixedParts = muPrim("add", aset(elmType), [aset(elmType), aset(elmType)], [fixedParts, mkVar(vp)], p.src);
    }
-   subject_minus_fixed = muPrim("subtract", aset(elmType), [aset(elmType), aset(elmType)], [subject, fixed], p@\loc);
+   subject_minus_fixed = muPrim("subtract", aset(elmType), [aset(elmType), aset(elmType)], [subject, fixed], p.src);
    
    MuExp setPatTrueCont =
         isEmpty(subjects) ? ( ( isEmpty(fixedLiterals) && isEmpty(fixedVars) && isEmpty(fixedMultiVars) )
@@ -1818,7 +1818,7 @@ MuExp translateSetPat(p:(Pattern) `{<{Pattern ","}* _>}`, AType subjectType, MuE
         block = setPatTrueCont;
    } else {
         block = muBlock([ muConInit(fixed, fixedParts),
-                          muIfElse(muPrim("subset", aset(elmType), [aset(elmType), aset(elmType)], [fixed, subject], p@\loc),
+                          muIfElse(muPrim("subset", aset(elmType), [aset(elmType), aset(elmType)], [fixed, subject], p.src),
                                    muBlock([ *(leftMostVar <= 0 ? [muAssign(subject, subject_minus_fixed)] : [muConInit(subjects[leftMostVar-1], subject)]),
                                              setPatTrueCont]),
                                    muFail(getFail(my_btscope), comment="set pat5"))
@@ -2112,8 +2112,8 @@ MuExp translatePatAsListElem(p:(Pattern) ``, Lookahead looka
                                ]),
                        falseCont);
     }
-    var = mkVar(prettyPrintName(name), name@\loc);
-    if(isDefinition(name@\loc)){
+    var = mkVar(prettyPrintName(name), name.src);
+    if(isDefinition(name.src)){
         return muIfElse(muLessNativeInt(cursor, sublen),
                         muBlock([ muVarInit(var, muSubscript(subject, subjectType, cursor)),
                                   muIncNativeInt(cursor, muCon(1)), 
@@ -2149,7 +2149,7 @@ MuExp translatePatAsListElem(p:(Pattern) ` `, Lookahead look
       code = muIfElse(check, muBlock([ muIncNativeInt(cursor, muCon(1)), trueCont ]),
                              falseCont);
    } else {
-       var = mkVar(prettyPrintName(name), name@\loc);
+       var = mkVar(prettyPrintName(name), name.src);
        var.atype = getType(tp);
        
        code = muIfElse(check, muBlock([ muVarInit(var, muSubscript(subject, subjectType, cursor)), muIncNativeInt(cursor, muCon(1)), trueCont ]),
@@ -2184,15 +2184,15 @@ bool isUsed(MuExp _var, MuExp _exp){
 }
 
 MuExp translatePatAsListElem(p:(Pattern) `*`, Lookahead lookahead, AType subjectType, MuExp subject, MuExp sublen, MuExp cursor, int posInPat, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, MuExp restore=muBlock([])) {
-    return translateMultiVarAsListElem(mkVar(p), isDefinition(name@\loc), lookahead, subjectType, subject, sublen, cursor, posInPat, getEnter(p, btscopes), trueCont, falseCont, restore=restore);
+    return translateMultiVarAsListElem(mkVar(p), isDefinition(name.src), lookahead, subjectType, subject, sublen, cursor, posInPat, getEnter(p, btscopes), trueCont, falseCont, restore=restore);
 }
 
 MuExp translatePatAsListElem(p:(Pattern) `*`, Lookahead lookahead, AType subjectType, MuExp subject, MuExp sublen, MuExp cursor, int posInPat, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, MuExp restore=muBlock([])) {
-    return translateMultiVarAsListElem(mkVar(p), isDefinition(name@\loc), lookahead, subjectType, subject, sublen, cursor, posInPat, getEnter(p, btscopes), trueCont, falseCont, restore=restore);
+    return translateMultiVarAsListElem(mkVar(p), isDefinition(name.src), lookahead, subjectType, subject, sublen, cursor, posInPat, getEnter(p, btscopes), trueCont, falseCont, restore=restore);
 } 
 
 MuExp translatePatAsListElem(p:(Pattern) `* `, Lookahead lookahead, AType subjectType, MuExp subject, MuExp sublen, MuExp cursor, int posInPat, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, MuExp restore=muBlock([])) {
-    return translateMultiVarAsListElem(mkVar(p), isDefinition(name@\loc), lookahead, subjectType, subject, sublen, cursor, posInPat, getEnter(p, btscopes), trueCont, falseCont, restore=restore);
+    return translateMultiVarAsListElem(mkVar(p), isDefinition(name.src), lookahead, subjectType, subject, sublen, cursor, posInPat, getEnter(p, btscopes), trueCont, falseCont, restore=restore);
 }
 
 MuExp translatePatAsListElem(p:(Pattern) `+`, Lookahead lookahead, AType subjectType, MuExp subject, MuExp sublen, MuExp cursor, int posInPat, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, MuExp restore=muBlock([])) {
@@ -2307,8 +2307,8 @@ MuExp translatePat(p:(Pattern) ` : `, AType subjectT
     if(subjectAssigned){
          return translatePat(pattern, subjectType, subjectExp, btscopes, trueCont, falseCont, subjectAssigned=false, restore=restore);
     } else {
-        var = mkVar(prettyPrintName(name), name@\loc);
-        asg = isDefinition(name@\loc) ? muVarInit(var, subjectExp) : muAssign(var, subjectExp);
+        var = mkVar(prettyPrintName(name), name.src);
+        asg = isDefinition(name.src) ? muVarInit(var, subjectExp) : muAssign(var, subjectExp);
         return translatePat(pattern, subjectType, subjectExp, btscopes, muValueBlock(avalue(), [ asg, trueCont ]), falseCont, subjectAssigned=subjectAssigned, restore=restore);
     }
 }
@@ -2428,7 +2428,7 @@ MuExp translatePat(p:(Pattern) `  : `, ATyp
          return asubtype(subjectType, trType) ? trPat : muIfElse(muValueIsSubtypeOf(subjectExp, trType), trPat, falseCont);
     }
     str fuid = ""; int pos=0;           // TODO: this keeps type checker happy, why?
-     = getVariableScope(prettyPrintName(name), name@\loc);
+     = getVariableScope(prettyPrintName(name), name.src);
     ppname = prettyPrintName(name);
     var = muVar(ppname, fuid, pos, trType/*[alabel=ppname]*/, patternVariableId());
     trueCont2 = trueCont;
@@ -2450,7 +2450,7 @@ default BTINFO getBTInfo(Pattern p, BTSCOPE btscope, BTSCOPES btscopes)
 
 default MuExp translatePat(Pattern p, AType subjectType,  MuExp subjectExp, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont, bool subjectAssigned=false, MuExp restore=muBlock([])) { 
     //iprintln(p);
-    return muValueBlock(avalue(), [muThrow(muCon("could not translate pattern 

: "), p@\loc)]); + return muValueBlock(avalue(), [muThrow(muCon("could not translate pattern

: "), p.src)]); } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalStatement.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalStatement.rsc index fc0e0de78d7..54bfa55a8fd 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalStatement.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalStatement.rsc @@ -80,7 +80,7 @@ MuExp translate(s: (Statement) `assert ;`, BTSCOPES btsc if(assertsEnabled()){ return muIfExp(translate(expression), muCon(true), - muPrim("assert_fails", abool(), [astr()], [muCon("")], s@\loc)); + muPrim("assert_fails", abool(), [astr()], [muCon("")], s.src)); } return muCon(true); } @@ -89,7 +89,7 @@ MuExp translate(s: (Statement) `assert : while ( <{Expression ","}+ conditi if(containsAppend(body)){ writer = muTmpListWriter("listwriter_", fuid); code = muValueBlock(getType(s), - [ muConInit(writer, muPrim("open_list_writer", avalue(), [], [], s@\loc)), + [ muConInit(writer, muPrim("open_list_writer", avalue(), [], [], s.src)), loopBody, - muPrim("close_list_writer", avalue(), [avalue()], [writer], s@\loc) + muPrim("close_list_writer", avalue(), [avalue()], [writer], s.src) ]); } else { //code = loopBody; @@ -215,9 +215,9 @@ MuExp translate(s: (Statement) `

`) { return [moduleInfo( moduleName=moduleName, name=name, - src=m@\loc, + src=m.src, synopsis=synopsis, docs=sortedDocTags(tags), demo=(/demo|examples/ := moduleName), @@ -70,7 +70,7 @@ list[DeclarationInfo] extractDecl(str moduleName, d: (Declaration) ` list[DeclarationInfo] extractDecl(str moduleName, d: (Declaration) ` alias = ;`) { dtags = getTagContents(tags); - return [ aliasInfo(moduleName=moduleName, name="", signature="", src=d@\loc, synopsis=getSynopsis(dtags), docs=sortedDocTags(dtags))]; + return [ aliasInfo(moduleName=moduleName, name="", signature="", src=d.src, synopsis=getSynopsis(dtags), docs=sortedDocTags(dtags))]; } list[DeclarationInfo] extractDecl(str moduleName, d: (Declaration) ` tag on <{Type ","}+ types> ;`) @@ -94,7 +94,7 @@ list[DeclarationInfo] extractDecl(str moduleName, d: (Declaration) ` adtName = ""; return [dataInfo(moduleName=moduleName, name=adtName, signature="data ", - src=d@\loc, synopsis=getSynopsis(dtags), docs=sortedDocTags(dtags))]; + src=d.src, synopsis=getSynopsis(dtags), docs=sortedDocTags(dtags))]; } list[DeclarationInfo] extractDecl(str moduleName, d: (Declaration) ` data = <{Variant "|"}+ variants> ;`) { @@ -104,12 +104,12 @@ list[DeclarationInfo] extractDecl(str moduleName, d: (Declaration) ` infoVariants = [ genVariant(moduleName, variant) | variant <- variants ]; return dataInfo(moduleName=moduleName, name=adtName, signature="data ", - src=d@\loc, synopsis=getSynopsis(dtags), docs=sortedDocTags(dtags)) + infoVariants; + src=d.src, synopsis=getSynopsis(dtags), docs=sortedDocTags(dtags)) + infoVariants; } DeclarationInfo genVariant(str moduleName, v: (Variant) `(<{TypeArg ","}* _> )`) { signature = ""; - return constructorInfo(moduleName=moduleName, name="", signature="", src=v@\loc); + return constructorInfo(moduleName=moduleName, name="", signature="", src=v.src); } list[DeclarationInfo] extractDecl(str moduleName, d: (Declaration) ``) @@ -143,7 +143,7 @@ private DeclarationInfo extractFunctionDeclaration(str moduleName, FunctionDecla tags = getTagContents(fd.tags); - return functionInfo(moduleName=moduleName, name=fname, signature=signature, src=fd@\loc, synopsis=getSynopsis(tags), docs=sortedDocTags(tags), fullFunction=""); + return functionInfo(moduleName=moduleName, name=fname, signature=signature, src=fd.src, synopsis=getSynopsis(tags), docs=sortedDocTags(tags), fullFunction=""); } DeclarationInfo extractTestDecl(str moduleName, FunctionDeclaration fd) { @@ -152,7 +152,7 @@ DeclarationInfo extractTestDecl(str moduleName, FunctionDeclaration fd) { signature = ""; tags = getTagContents(fd.tags); - return testInfo(moduleName=moduleName, name=fname, src=fd@\loc, synopsis=getSynopsis(tags), fullTest=""); + return testInfo(moduleName=moduleName, name=fname, src=fd.src, synopsis=getSynopsis(tags), fullTest=""); } private Tree removeTags(Tree x) = visit(x) { diff --git a/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/SplitDocTag.rsc b/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/SplitDocTag.rsc index 0fd189694cd..f518f3743f9 100644 --- a/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/SplitDocTag.rsc +++ b/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/SplitDocTag.rsc @@ -25,8 +25,8 @@ void editModule(loc example) = editModule(parse(#start[Module], example).top); list[TextEdit] editsForModule(loc example) = rewriteDocTags(example); void editModule(Module m) { - edits = rewriteDocTags(m@\loc.top); - executeDocumentEdits([changed(m@\loc.top, edits)]); + edits = rewriteDocTags(m.src.top); + executeDocumentEdits([changed(m.src.top, edits)]); return; } diff --git a/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/TrimDoc.rsc b/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/TrimDoc.rsc index e7b10364ad2..422ad9171b4 100644 --- a/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/TrimDoc.rsc +++ b/src/org/rascalmpl/tutor/lang/rascal/tutor/conversions/TrimDoc.rsc @@ -16,7 +16,7 @@ void editModule(loc example) = editModule(parse(#start[Module], example).top); void editModule(start[Module] m) { n = rewriteDocTags(m); - writeFile(m@\loc.top, ""); + writeFile(m.src.top, ""); return; } From 1dd0c8c7b7ffd36593f1dd3c6360b36d2c555eb3 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 7 Apr 2026 14:34:10 +0200 Subject: [PATCH 15/16] replaced irreplacable anno definitions --- .../library/lang/rascal/ide/Outline.rsc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc b/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc index 786c7a91d33..d4a39d54a8c 100644 --- a/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc +++ b/src/org/rascalmpl/library/lang/rascal/ide/Outline.rsc @@ -6,21 +6,18 @@ import lang::rascal::\syntax::Rascal; import Map; import List; import String; + +data FunctionDeclaration(loc src = |unknown:///|, str label=""); -anno str node@label; -anno loc node@\loc; +data Declaration(loc src = |unknown:///|, str label=""); -data FunctionDeclaration(loc src = |unknown:///|); +data Name(loc src = |unknown:///|, str label=""); -data Declaration(loc src = |unknown:///|); +data QualifiedName(loc src = |unknown:///|, str label=""); -data Name(loc src = |unknown:///|); +data Signature(loc src = |unknown:///|, str label=""); -data QualifiedName(loc src = |unknown:///|); - -data Signature(loc src = |unknown:///|); - -data Prod(loc src = |unknown:///|); +data Prod(loc src = |unknown:///|, str label=""); node outline(start[Module] m) = outline(m.top); From c011080c2c2aa4619045ce79cf47a911fe7e1dcf Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 7 Apr 2026 15:28:22 +0200 Subject: [PATCH 16/16] improved upgrading of defaults --- .../upgrade/UpgradeAnnotationsToKeywordParameters.rsc | 8 +++++++- 1 file changed, 7 insertions(+), 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 342ee9585e9..d55a4345ba4 100644 --- a/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc +++ b/src/org/rascalmpl/library/lang/rascal/upgrade/UpgradeAnnotationsToKeywordParameters.rsc @@ -19,7 +19,13 @@ Tree update(Tree m) = 'data ( = );` when Expression init := getInitializer(t), Name name2 := getName(name) - case (Expression) `@ ? ` => (Expression) `.` + case (Expression) `@\\loc ? |unknown:///|` => (Expression) `.src` + when Name name2 := getName(name) + + case (Expression) `@\\loc ? |unknown:///|(_,_,\<_,_\>,\<_,_\>)` => (Expression) `.src` + when Name name2 := getName(name) + + case (Expression) `@ ? ` => (Expression) `. ? ` when Name name2 := getName(name) case (Expression) `@` => (Expression) `.`