Skip to content

Commit

Permalink
Fixed type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 5, 2024
1 parent 2b4742e commit 9f1c78f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 37 deletions.
7 changes: 4 additions & 3 deletions src/org/rascalmpl/core/library/MeasureParsing.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import IO;
import ValueIO;

data PathConfig(
list[loc] resources = [],
list[loc] generatedResources = []
loc resources = |unknown:///|,
loc generatedResources = |unknown:///|,
loc generatedSources = |unknown:///|
);

void main(){
Expand All @@ -29,7 +30,7 @@ void main(){
parse_time = 0;
read_time = 0;
write_time = 0;
for(int i <- [1..10]){
for(int _ <- [1..10]){
for(qualifiedModuleName <- ["Boolean", "Type", "ParseTree", "List"]){
mloc = getModuleLocation(qualifiedModuleName, pcfg);
ploc = |file:///tmp/<qualifiedModuleName>.parsetree|;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import ParseTree;
import util::Reflective;

import util::FileSystem;
import ValueIO;

//import lang::rascalcore::compile::Compile;

Expand Down Expand Up @@ -298,7 +297,7 @@ TestResults runTests(list[str] names, str base, PathConfig pcfg){
try {
prog = base == "" ? tst : (base + "::" + tst);
println("TYPECHECKING <prog>");
mname2msgs = filterErrors(checkModules([prog], rascalTypePalConfig(), pcfg));
mname2msgs = filterErrors(checkModules([prog], getTypePalCompilerConfig(pcfg)));
iprintln(mname2msgs);
all_test_msgs += mname2msgs;
} catch value e:
Expand Down Expand Up @@ -398,7 +397,7 @@ bool blacklisted(str qualifiedModuleName){
return contains(qualifiedModuleName, "Java18");
}

bool whitelisted(str qualifiedModuleName){
bool whitelisted(str _qualifiedModuleName){
return true;
//for(s <- {"lang::rascal"}){
// if(contains(qualifiedModuleName, s)) return true;
Expand Down Expand Up @@ -448,7 +447,7 @@ void allFiles(PathConfig pcfg = pathConfig(
}
println("\>\>\> <ncount>: CHECKING <qualifiedModuleName> (N:<size(modulePaths)>/E:<size(problems)>/C:<size(crashed)>/S:<nskipped>)");
try {
modulesAndmsgs = filterErrors(checkModules([qualifiedModuleName], rascalTypePalConfig(), pcfg));
modulesAndmsgs = filterErrors(checkModules([qualifiedModuleName], getTypePalCompilerConfig(pcfg)));
//modulesAndmsgs = (qualifiedModuleName : filterErrors(compile(qualifiedModuleName, rascalTypePalConfig(),pcfg)));
if(modulesAndmsgs[qualifiedModuleName]?) iprintln(modulesAndmsgs);
problems += modulesAndmsgs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import lang::rascalcore::check::Checker;
import analysis::typepal::TypePal;
import analysis::typepal::TestFramework;

import IO;

start syntax Modules
= Module+ modules;

// ---- Testing ---------------------------------------------------------------

TModel rascalTModelForTestModules(Tree pt, bool debug=false){
ms = getInlineImportAndExtendGraph(pt, getDefaultTestingPathConfig());
TypePalConfig config=rascalTypePalConfig(getDefaultTestingPathConfig());
TypePalConfig config=getTypePalCompilerConfig(getDefaultTestingPathConfig());
if(debug){
config = config[logImports = true];
}
Expand All @@ -39,4 +37,4 @@ void testModules(str names...) {
list[str] allTests = ["adt", "adtparam", "alias", "assignment", "datadecl", "exp", "fields", "fundecl",
"imports", "operators", "pat", "scope", "splicepats", "stats"/*,"syntax1", "syntax2", "syntax3"*/];

value main() = testModules();
void main() = testModules();
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module lang::rascalcore::check::tests::PatternUsingStdLibTCTests

import lang::rascalcore::check::tests::StaticTestingUtils;

import ParseTree;

test bool PicoQuoted1() =
checkOK("Program program := t1;",
initialDecls = ["Tree t1 = (Program) `begin declare x: natural; x := 10 end`;"],
Expand All @@ -15,12 +13,12 @@ test bool PicoQuoted2() =
initialDecls = ["Tree t1 = (Program) `begin declare x: natural; x := 10 end`;"],
importedModules = ["ParseTree", "lang::pico::\\syntax::Main"]);

test bool PicoQuoted2() =
test bool PicoQuoted3() =
checkOK(" (Program) `begin \<Declarations decls\> \<{Statement \";\"}* stats\> end` := t1; ",
initialDecls = ["Tree t1 = (Program) `begin declare x: natural; x := 10 end`;"],
importedModules = ["ParseTree", "lang::pico::\\syntax::Main"]);

test bool PicoQuoted3() =
test bool PicoQuoted4() =
checkOK("if ((Program) `begin \<Declarations decls\> \<{Statement \";\"}* stats\> end` := t1) {
' x = (Program) `begin \<Declarations decls\> \<{Statement \";\"}* stats\> end`;
'}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool unexpectedType(str stmts, list[str] importedModules = [], list[str] initial

// NOTE: type checker does not yet support analysis of uninitialized variables, therefore this check always succeeds, for now.

bool uninitialized(str stmts, list[str] importedModules = [], list[str] initialDecls = []) = true;
bool uninitialized(str _stmts, list[str] _importedModules = [], list[str] _initialDecls = []) = true;

//bool uninitialized(str stmts, list[str] importedModules = [], list[str] initialDecls = []) =
//check(stmts, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ void main([]) { // entry point for the RASCAL interpreter
}

int main(){
work();
return work();
}

int work() { // entry point for the RASCAL compiler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module lang::rascalcore::compile::Examples::Tst0



int f(int n, bool b = false) = 0;
int f(int n, str s, bool b = false) = 0;
int f(int n, bool b = false) = 0;
int f(int n) = 0;

value main() = f(0);
module lang::rascalcore::compile::Examples::Tst0
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import lang::rascal::\syntax::Rascal;
import lang::rascalcore::grammar::definition::Literals;
import lang::rascalcore::check::AType;

test bool tstLiteral1() = literal("") == prod(lit(""),[]);
test bool tstLiteral2() = literal("a") == prod(lit("a"),[\char-class([range(97,97)])]);
test bool tstLiteral1() = literal("") == prod(alit(""),[]);
test bool tstLiteral2() = literal("a") == prod(alit("a"),[\achar-class([arange(97,97)])]);
test bool tstLiteral3() = literal("ab") ==
prod(lit("ab"),[\char-class([range(97,97)]),\char-class([range(98,98)])]);
prod(alit("ab"),[\achar-class([arange(97,97)]),\achar-class([arange(98,98)])]);

test bool tstCiLiteral1() = ciliteral("") == prod(cilit(""),[]);
test bool tstCiLiteral2() = ciliteral("a") == prod(cilit("a"),[\char-class([range(97,97)])]);
test bool tstCiLiteral1() = ciliteral("") == prod(acilit(""),[]);
test bool tstCiLiteral2() = ciliteral("a") == prod(acilit("a"),[\achar-class([arange(97,97)])]);
test bool tstCiLiteral3() = ciliteral("ab") ==
prod(cilit("ab"),[\char-class([range(97,97)]),\char-class([range(98,98)])]);
prod(acilit("ab"),[\achar-class([arange(97,97)]),\achar-class([arange(98,98)])]);

test bool tstStr2Syms1() = str2syms("") == [];
test bool tstStr2Syms2() = str2syms("a") == [\char-class([range(97,97)])];
test bool tstStr2Syms3() = str2syms("ab") == [\char-class([range(97,97)]),\char-class([range(98,98)])];
test bool tstStr2Syms2() = str2syms("a") == [\achar-class([arange(97,97)])];
test bool tstStr2Syms3() = str2syms("ab") == [\achar-class([arange(97,97)]),\achar-class([arange(98,98)])];

test bool tsCistr2syms1() = cistr2syms("") == [];
test bool tsCistr2syms2() = cistr2syms("a") == [\char-class([range(97,97)])];
test bool tsCistr2syms3() = cistr2syms("A") == [\char-class([range(65,65)])];
test bool tsCistr2syms2() = cistr2syms("a") == [\achar-class([arange(97,97)])];
test bool tsCistr2syms3() = cistr2syms("A") == [\achar-class([arange(65,65)])];

test bool tstUnescapeSC1() = unescapeLiteral((StringConstant) `"a"`) == "a";
test bool tstUnescapeSC2() = unescapeLiteral((StringConstant) `"\\t"`) == "\t";
Expand Down

0 comments on commit 9f1c78f

Please sign in to comment.