Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,24 @@ int commonPrefix(list[str] rdir, list[str] rm){
}
return size(rm);
}
@memo{expireAfter(minutes=5),maximumSize(500)}

@synopsis{Find the module name corresponding to a given module location via its (src, tpl or logical) location}
str getRascalModuleName(loc moduleLoc, PathConfig pcfg){
str getRascalModuleName(loc moduleLoc, PathConfig pcfg)
= getRascalModuleName1(moduleLoc.top, pcfg);

//@memo{expireAfter(minutes=5),maximumSize(500)}
private str getRascalModuleName1(loc moduleLoc, PathConfig pcfg){
modulePath = moduleLoc.path;

rscFile = endsWith(modulePath, "rsc");
tplFile = endsWith(modulePath, "tpl");
if(isLogicalLoc(moduleLoc)){
path = moduleLoc.path;
if(path[0] == "/"){
path = path[1..];
}
return replaceAll(path, "/", "::");
}
if(!( rscFile || tplFile )){
throw "Not a Rascal .rsc or .tpl file: <moduleLoc>";
}

rscFile = endsWith(modulePath, "rsc");

// Find matching .rsc file in source directories
if(rscFile){
Expand All @@ -127,10 +128,17 @@ str getRascalModuleName(loc moduleLoc, PathConfig pcfg){
moduleName = moduleName[1..];
}
moduleName = replaceAll(moduleName, "/", "::");
// if(moduleName == "library::List"){
// println("getRascalModuleName: <moduleLoc> =\> <moduleName>");
// }
return moduleName;
}
}
}
tplFile = endsWith(modulePath, "tpl");
if(!( rscFile || tplFile )){
throw "Not a Rascal .rsc or .tpl file: <moduleLoc>";
}

// Find longest matching .tpl file in library directories

Expand All @@ -151,17 +159,19 @@ str getRascalModuleName(loc moduleLoc, PathConfig pcfg){
}
modulePathReversed = reverse(modulePathAsList);

int longestSuffix = 0;
for(loc dir <- pcfg.libs){
int largestSuffix = 0;
bool found = false;
for(loc dir <- pcfg.libs, !found){
dir = dir + "rascal";
dpath = dir.path;

while(dpath[0] == "/"){
dpath = dpath[1..];
}

for(loc file <- find(dir, "tpl")){
candidate = replaceFirst(file.path, dpath, "");
candidate = replaceFirst(file.path, dpath, "");

<candidate, ext> = splitFileExtension(candidate);
while(candidate[0] == "/"){
candidate = candidate[1..];
Expand All @@ -172,21 +182,25 @@ str getRascalModuleName(loc moduleLoc, PathConfig pcfg){
if(lastName[0] == "$"){
candidateAsList = [*candidateAsList[..-1],lastName[1..]];
}
// println("cand: <candidateAsList>, modpath: <modulePathAsList>");

n = commonPrefix(reverse(candidateAsList), modulePathReversed);
if(n > longestSuffix){
longestSuffix = n;

if(n > largestSuffix){
largestSuffix = n;
}
}
}

if(longestSuffix > 0){
if(largestSuffix > 0){
lastName = modulePathAsList[-1];
if(lastName[0] == "$"){
modulePathAsList = [*modulePathAsList[..-1],lastName[1..]];
}
return intercalate("::", modulePathAsList[size(modulePathAsList) - longestSuffix .. ]);
res = intercalate("::", modulePathAsList[size(modulePathAsList) - largestSuffix .. ]);
//if(contains(res, "List")){
//println("getRascalModuleName: <moduleLoc> =\> <res>");
//}
return res;
}
throw "No module name found for <moduleLoc>;\nsrcs=<pcfg.srcs>;\nlibs=<pcfg.libs>";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ public RascalCompilerConfig getFlyBytesCompilerConfig(bool keep=true){
// ---- salix -----------------------------------------------------------------

public PathConfig getSalixPathConfig(bool keep = false) {
return makePathConfig([ REPO + "salix-core/src/main/rascal", REPO + "salix-contrib/src/main/rascal" ],
[ RASCAL ],
return makePathConfig([ REPO + "salix-core/src/main/rascal", REPO + "salix-contrib/src/main/rascal",
REPO + "rascal/src/org/rascalmpl/library"],
[ ],
keep=keep);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import util::FileSystem;
import util::PathConfig;
import IO;
import Message;
import lang::rascalcore::check::ModuleLocations;

private void runChecker(PathConfig pcfg, bool (loc m) validModule) {
result = check([m | src <- pcfg.srcs, m <- find(src, "rsc"), validModule(m)], rascalCompilerConfig(pcfg));
Expand All @@ -44,12 +45,46 @@ void main(loc repoRoot = |file:///Users/paulklint/git/|, loc tplRoot = |file:///
salixContribPcfg = pathConfig(srcs=[repoRoot + "salix-contrib/src/main/rascal"], bin=tplRoot + "salix-core", libs=[rascalPcfg.bin, salixCorePcfg.bin]);

println("**** Checking rascal");
// // iprintln(check([|file:///Users/paulklint/git/rascal/src/org/rascalmpl/library/ParseTree.rsc|,
// // |file:///Users/paulklint/git/rascal/src/org/rascalmpl/library/String.rsc|
// // ], rascalCompilerConfig(rascalPcfg)));

// runChecker(rascalPcfg, bool (loc m) { return true; });

runChecker(rascalPcfg, bool (loc m) { return /lang.rascal/ !:= m.path && /experiments/ !:= m.path && /lang.rascal.*tests/ !:= m.path; });
// println(getRascalModuleName(|file:///Users/paulklint/git/rascal/src/org/rascalmpl/library/lang/json/IO.rsc|, salixCorePcfg));
// println(getRascalModuleName(|file:///Users/paulklint/rascal-tpls/rascal/rascal/lang/json/$IO.tpl|, salixCorePcfg));

// println(getRascalModuleName(|file:///Users/paulklint/git/rascal/src/org/rascalmpl/library/IO.rsc|, salixCorePcfg));
// println(getRascalModuleName(|file:///Users/paulklint/rascal-tpls/rascal/rascal/$IO.tpl|, salixCorePcfg));

// println(getRascalModuleName(|file:///Users/paulklint/git/rascal/src/org/rascalmpl/library/lang/rascal/tests/libraries/IO.rsc|, salixCorePcfg));
// println(getRascalModuleName(|file:///Users/paulklint/rascal-tpls/rascal/rascal/$IO.tpl|, salixCorePcfg));

println("**** Checking salix-core");
runChecker(salixCorePcfg, bool (loc m) { return true; });
// println("**** Checking salix-core");
// runChecker(salixCorePcfg, bool (loc m) { return true; });

println("**** Checking salix-contrib");
//iprintln(check([|file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/util/Mode.rsc|], rascalCompilerConfig(salixContribPcfg)));
// iprintln(check([
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/mermaid/Mermaid.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/mermaid/Demo.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/jsplumb/Demo.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/mermaid/FlowChart.rsc|,
// |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/util/Mode.rsc|,
// |file:///Users/paulklint/git/salix-contrib/src/main/rascal/Main.rsc|
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/ace/Editor.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/cytoscape/Demo.rsc|,
// //|file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/canvas/Demo.rsc|
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/canvas/Heart.rsc|,
// //|file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/ace/Demo.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/canvas/Canvas.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/charts/Charts.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/jsplumb/JSPlumb.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/cytoscape/Cytoscape.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/charts/Demo.rsc|,
// // |file:///Users/paulklint/git/salix-contrib/src/main/rascal/salix/mermaid/ClassDiagram.rsc|
// ], rascalCompilerConfig(salixContribPcfg)));

runChecker(salixContribPcfg, bool (loc m) { return true; });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,35 @@ POSSIBILITY OF SUCH DAMAGE.
//@bootstrapParser
module lang::rascalcore::compile::Examples::Tst2


import IO;
import util::UUID;
import util::PathConfig;
import lang::rascalcore::check::ModuleLocations;

private loc testLibraryLoc = |memory://myTestLibrary-<uuid().authority>/|;

void showName(loc m, PathConfig pcfg){
println("<m> =\> <getRascalModuleName(m, pcfg)>");
}
void confusion() {
listTPL = testLibraryLoc + "/rascal/$List.tpl";
writeFile( listTPL, "$List.tpl (only file name matters, content irrelevant)");
testListTPL = testLibraryLoc + "/rascal/lang/rascal/tests/library/$List.tpl";
writeFile(testListTPL, "lang/rascal/tests/library/$List.tpl (content irrelevant)");
pcfg = pathConfig(srcs = [], libs=[testLibraryLoc]);

int N = 0;
listSrc = |project://rascal/src/org/rascalmpl/library/List.rsc|;
testListSrc = |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/List.rsc|;
println("\nConfusion");
showName(listSrc, pcfg);
showName(testListSrc, pcfg);

//rename library => libraries
remove(testListTPL);
renamedTestListTPL = testLibraryLoc + "/rascal/lang/rascal/tests/libraries/$List.tpl";
writeFile(renamedTestListTPL, "lang/rascal/tests/libraries/$List.tpl (content irrelevant)");

void main(){
N += 1;
println("\nNo confusion after renaming library to libraries");
showName(listSrc, pcfg);
showName(testListSrc, pcfg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,25 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
module lang::rascalcore::compile::Examples::Tst4
import lang::rascalcore::compile::Examples::Tst2;


import IO;

data R = r(void(value) f,
void(value,value) g)
;

R makeR(){
void f1(int x){ println("f1(<x>)"); }

void f2(str x){ println("f2(<x>)"); }

void f3(int x, int y) { println("f3(<x>,<y>)"); }

void f4(str x, str y) { println("f4(<x>,<y>)"); }

return r(f1 + f2, f3 + f4);
}

void main(){
N = "a";
}
makeR().g("a", "b");
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import IO;
test bool testOvertakeNullableBug() {
standardParser = parser(#start[Module], allowRecovery=false, allowAmbiguity=true);
recoveryParser = parser(#start[Module], allowRecovery=true, allowAmbiguity=true);
loc source = |std:///lang/rascal/tests/library/analysis/statistics/DescriptiveTests.rsc|;
loc source = |std:///lang/rascal/tests/libraries/analysis/statistics/DescriptiveTests.rsc|;
input = readFile(source);

testDeleteUntilEol(standardParser, recoveryParser, source, input, 200, 100, 100, 100, begin=561, end=561);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::Boolean
module lang::rascal::tests::libraries::Boolean
/*******************************************************************************
* Copyright (c) 2009-2015 CWI
* All rights reserved. This program and the accompanying materials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.eclipse.org/legal/epl-v10.html
}
@contributor{Jouke Stoel - Jouke.Stoel@cwi.nl - CWI}
module lang::rascal::tests::library::DateTime
module lang::rascal::tests::libraries::DateTime

import DateTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::IO
module lang::rascal::tests::libraries::IO

import IO;
import DateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI}
@contributor{Paul Klint - Paul.Klint@cwi.nl - CWI}
@contributor{Bert Lisser - Bert.Lisser@cwi.nl - CWI}
module lang::rascal::tests::library::Integer
module lang::rascal::tests::libraries::Integer

import util::Math;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@contributor{Paul Klint - Paul.Klint@cwi.nl - CWI}
@contributor{Bert Lisser - Bert.Lisser@cwi.nl - CWI}
@contributor{Vadim Zaytsev - vadim@grammarware.net - UvA}
module lang::rascal::tests::library::List
module lang::rascal::tests::libraries::List

import Exception;
import List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
@contributor{Paul Klint - Paul.Klint@cwi.nl - CWI}
@contributor{Vadim Zaytsev - vadim@grammarware.net - UvA}
module lang::rascal::tests::library::ListRelation
module lang::rascal::tests::libraries::ListRelation

import ListRelation;
import List; // needed for slices used for dynamic type checks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@contributor{Anastasia Izmaylova - A.Izmaylova@cwi.nl - CWI}
@contributor{Bert Lisser - Bert.Lisser@cwi.nl - CWI}
@contributor{Vadim Zaytsev - vadim@grammarware.net - UvA}
module lang::rascal::tests::library::Map
module lang::rascal::tests::libraries::Map

import Map;
import Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI}
@contributor{Paul Klint - Paul.Klint@cwi.nl - CWI}
@contributor{Bert Lisser - Bert.Lisser@cwi.nl - CWI}
module lang::rascal::tests::library::Math
module lang::rascal::tests::libraries::Math

import util::Math;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::Node
module lang::rascal::tests::libraries::Node

import Node;
import ValueIO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::Number
module lang::rascal::tests::libraries::Number
/*******************************************************************************
* Copyright (c) 2009-2015 CWI
* All rights reserved. This program and the accompanying materials
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::Relation
module lang::rascal::tests::libraries::Relation
/*******************************************************************************
* Copyright (c) 2009-2015 CWI
* All rights reserved. This program and the accompanying materials
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::Set
module lang::rascal::tests::libraries::Set
/*******************************************************************************
* Copyright (c) 2009-2015 CWI
* All rights reserved. This program and the accompanying materials
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::String
module lang::rascal::tests::libraries::String
/*******************************************************************************
* Copyright (c) 2009-2015 CWI
* All rights reserved. This program and the accompanying materials
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::Type
module lang::rascal::tests::libraries::Type

import Type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@contributor{Paul Klint - Paul.Klint@cwi.nl - CWI}
@contributor{Arnold Lankamp - Arnold.Lankamp@cwi.nl}
@contributor{Bert Lisser - Bert.Lisser@cwi.nl - CWI}
module lang::rascal::tests::library::ValueIO
module lang::rascal::tests::libraries::ValueIO

import ValueIO;
import util::UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::analysis::diff::edits::HiFiTreeDiffTests
module lang::rascal::tests::libraries::analysis::diff::edits::HiFiTreeDiffTests

extend analysis::diff::edits::ExecuteTextEdits;
extend analysis::diff::edits::HiFiLayoutDiff;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@ignoreCompiler{Fix failing tests}
module lang::rascal::tests::library::analysis::formalconcepts::FCATest
module lang::rascal::tests::libraries::analysis::formalconcepts::FCATest

import util::Math;
import Set;
Expand Down Expand Up @@ -71,7 +71,7 @@ bool checkNoUnRelatedConcepts(rel[&TObject, &TAttribute] input) {
}

test bool fcaHasExpectedOutput() {
result = fca(readCxt(|std:///lang/rascal/tests/library/analysis/formalconcepts/FCxt1.cxt|));
reference = readBinaryValueFile(#ConceptLattice[str,str], |std:///lang/rascal/tests/library/analysis/formalconcepts/FCxt1.fca|);
result = fca(readCxt(|std:///lang/rascal/tests/libraries/analysis/formalconcepts/FCxt1.cxt|));
reference = readBinaryValueFile(#ConceptLattice[str,str], |std:///lang/rascal/tests/libraries/analysis/formalconcepts/FCxt1.fca|);
return result == reference;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module lang::rascal::tests::library::analysis::graphs::GraphTests
module lang::rascal::tests::libraries::analysis::graphs::GraphTests
/*******************************************************************************
* Copyright (c) 2009-2015 CWI
* All rights reserved. This program and the accompanying materials
Expand Down
Loading
Loading