-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Status of Rascal compiler project per October 23, 2023
Status of Rascal compiler project (for the benefit of picking this project up in a few weeks/month) - 12 compiled tests (compiled with interpreted compiler) still fail (see below) - All Rascal test files can be compiled by the compiled Rascal compiler - There are still the following glitches in generated code: - rascal.lang.rascal.tests.functionality.$PatternSet1Tests - rascal.lang.rascal.tests.functionality.$PatternList1Tests - 2 x issues in $ParseTree - 2 x issue rascal.lang.manifest.$IO - 1 x issue in rascal.lang.rascal.tests.concrete.$Syntax3 - In $RascalConfig, $T0 = $TF.nodeType() is not sorted correctly (happens intermittently) - More validation is needed of code generated by the interpreted resp. compiled compiler Finally, the bootstrap is not yet complete: the compiled compiled has not yet compiled itself. 12 compiled tests (compiled with interpreted compiler) that still fail: rascal.lang.rascal.tests.basic.$FunctionsTests curryAConstructor_287A8422_287(rascal.lang.rascal.tests.basic.$FunctionsTests) selfApplyCurry_297A8600_297(rascal.lang.rascal.tests.basic.$FunctionsTests) org.rascalmpl.exceptions.Throw: |TODO:///|: AssertionFailed("") returnOfAnInstantiatedGenericFunction_273A8025_273(rascal.lang.rascal.tests.basic.$FunctionsTests) java.lang.NullPointerException rascal.lang.rascal.tests.basic.$IOTests findResourcesWorks_233A6747_233(rascal.lang.rascal.tests.basic.$IOTests) java.lang.UnsupportedOperationException: Opaque URI schemes are not supported; the scheme-specific part must start with a / character. rascal.lang.rascal.tests.basic.$BooleansTests compositeOrCntBTLast_232A4874_232(rascal.lang.rascal.tests.basic.$BooleansTests) org.opentest4j.AssertionFailedError: expected: <true> but was: <false> shortCircuiting_53A1733_53(rascal.lang.rascal.tests.basic.$BooleansTests) org.opentest4j.AssertionFailedError: expected: <true> but was: <false> rascal.lang.rascal.tests.library.$ValueIOTests textParametrizedAdt3_80A2583_80(rascal.lang.rascal.tests.library.$ValueIOTests) org.opentest4j.AssertionFailedError: expected: <true> but was: <false> textParametrizedAdt2_79A2510_79(rascal.lang.rascal.tests.library.$ValueIOTests) org.opentest4j.AssertionFailedError: expected: <true> but was: <false> rascal.lang.rascal.tests.functionality.$StatementTests fail5_207A5845_207(rascal.lang.rascal.tests.functionality.$StatementTests) org.opentest4j.AssertionFailedError: expected: <true> but was: <false> rascal.lang.rascal.tests.functionality.$PatternSet1Tests matchSetLists8_669A16615_669(rascal.lang.rascal.tests.functionality.$PatternSet1Tests) java.lang.Error: Unresolved compilation problem: This method must return a result of type IBool rascal.lang.rascal.tests.functionality.$PatternList1Tests matchListTuples8_700A13749_700(rascal.lang.rascal.tests.functionality.$PatternList1Tests) java.lang.Error: Unresolved compilation problem: This method must return a result of type IBool rascal.lang.rascal.tests.concrete.$Patterns4Tests optionalNotPresentIsFalse_24A304_24(rascal.lang.rascal.tests.concrete.$Patterns4Tests) org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
- Loading branch information
Showing
7 changed files
with
108 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/org/rascalmpl/core/library=UTF-8 | ||
encoding//target/generated-test-resources=UTF-8 | ||
encoding//target/generated-test-sources=UTF-8 | ||
encoding/<project>=UTF-8 | ||
encoding/src=UTF-8 | ||
encoding/test=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 30 additions & 151 deletions
181
src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,154 +1,33 @@ | ||
module lang::rascalcore::compile::Examples::Tst0 | ||
|
||
//module lang::rascal::tests::basic::Equality | ||
|
||
import util::Math; | ||
import Set; | ||
import Map; | ||
import Type; | ||
import Node; | ||
|
||
// the only way two values can be equal while their run-time types are not is due to conversion between int, real, rat by `==` | ||
test bool canonicalTypes(&T x, &Y y) = x == y ==> (typeOf(x) == typeOf(y)) || size({typeOf(x), typeOf(y)} & {\int(), \real(), \rat()}) > 1; | ||
|
||
test bool canonicalTypesRegression1() = canonicalTypes(0.0, 0); | ||
test bool canonicalTypesRegression2() = canonicalTypes(0r, 0); | ||
test bool canonicalTypesRegression3() = canonicalTypes(0r, 0.0); | ||
|
||
// values have an equivalence relation | ||
test bool reflexEq1(value x) = x == x; | ||
test bool transEq1(value x, value y, value z) = (x == y && y == z) ==> (x == z); | ||
test bool commutativeEq1(value x, value y) = (x == y) <==> (y == x); | ||
|
||
// the matching operator is also an equivalence relation on values: | ||
test bool reflexEq2(value x) = x := x; | ||
test bool transEq2(value x, value y, value z) = (x := y && y := z) ==> (x := z); | ||
test bool commutativeEq2(value x, value y) = (x := y) <==> (y := x); | ||
|
||
// equality subsumes matching, but we focus on nodes to avoid problems with num coercions of `==`: | ||
test bool allEqualValuesMatch(node a, node b) = a == b ==> a := b; | ||
test bool noMatchImpliesUnequal(node a, node b) = !(a := b) ==> a != b; | ||
|
||
test bool matchIsEqualityModuloKeywordFields(node x, node y) | ||
= (unsetRec(x) == unsetRec(y)) <==> x := y; | ||
|
||
// values have an equivalence relation, and by requiring the arguments to have the same types we may trigger bugs sooner: | ||
test bool transEqSame(&Same x, &Same y, &Same z) = (x == y && y == z) ==> (x == z); | ||
test bool commutativeEqSame(&Same x, &Same y) = (x == y) <==> (y == x); | ||
|
||
// values are partially ordered | ||
test bool reflexLTE(value x) = (x <= x); | ||
test bool antiSymmetricLTE(value x, value y) = (x <= y && y <= x) ==> (x == y); | ||
test bool transLTE(value x, value y, value z) = (x <= y && y <= z) ==> x <= z; | ||
|
||
// values are partially ordered, and by requiring the arguments to have the same type we may trigger bugs sooner: | ||
@Ignore | ||
test bool antiSymmetricLTESame(&Same <: node x , &Same <: node y) = (x <= y && y <= x) ==> (x == y); | ||
test bool transLTESame(&Same <: node x, &Same <: node y, &Same <: node z) = (x <= y && y <= z) ==> x <= z; | ||
|
||
@Ignore | ||
test bool antiSymmetricLTEWithKeywordParamsLt1() = antiSymmetricLTESame(""(), ""(x = 3)); | ||
@Ignore | ||
test bool antiSymmetricLTEWithKeywordParamsLt2() = antiSymmetricLTESame(""(x = 2), ""(x = 3)); | ||
@Ignore | ||
test bool antiSymmetricLTEWithKeywordParamsEq() = antiSymmetricLTESame(""(x = 3), ""(x = 3)); | ||
|
||
// numbers are totally ordered | ||
test bool numTotalLTE1(num x, num y) = x <= y || y <= x; | ||
test bool numAntiSymmetricLTE(num x, num y) = (x <= y && y <= x) ==> (x == y); | ||
test bool numTransLTE(num x, num y, num z) = (x <= y && y <= z) ==> (x <= z); | ||
test bool numValueReflex(num x) { value y = x; return x == y && y == x; } | ||
|
||
// ints are totally ordered | ||
test bool intTotalLTE(int x, int y) = x <= y || y <= x; | ||
test bool intAntiSymmetricLTE(int x, int y) = (x <= y && y <= x) ==> (x == y); | ||
test bool intTransLTE(int x, int y, int z) = (x <= y && y <= z) ==> (x <= z); | ||
test bool intValueReflex(int x) { value y = x; return x == y && y == x; } | ||
|
||
// reals are totally ordered | ||
test bool realTotalLTE(real x, real y) = x <= y || y <= x; | ||
test bool realAntiSymmetricLTE(real x, real y) = (x <= y && y <= x) ==> (x == y); | ||
test bool realTransLTE(real x, real y, real z) = (x <= y && y <= z) ==> (x <= z); | ||
test bool realValueReflex(real x) { value y = x; return x == y && y == x; } | ||
|
||
// rat are totally ordered | ||
test bool ratTotalLTE(rat x, rat y) = x <= y || y <= x; | ||
test bool ratAntiSymmetricLTE(rat x, rat y) = (x <= y && y <= x) ==> (x == y); | ||
test bool ratTransLTE(rat x, rat y, rat z) = (x <= y && y <= z) ==> (x <= z); | ||
test bool ratValueReflex(rat x) { value y = x; return x == y && y == x; } | ||
|
||
// strings are totally ordered | ||
test bool numTotalLTE2(str x, str y) = x <= y || y <= x; | ||
test bool strAntiSymmetricLTE(str x, str y) = (x <= y && y <= x) ==> (x == y); | ||
test bool strTransLTE(str x, str y, str z) = (x <= y && y <= z) ==> x <= z; | ||
test bool strValueReflex(rat x) { value y = x; return x == y && y == x; } | ||
|
||
// lists are partially ordered | ||
test bool listReflexLTE(list[value] x) = (x <= x); | ||
test bool listAntiSymmetricLTE(list[value] x, list[value] y) = (x <= y && y <= x) ==> (x == y); | ||
test bool listTransLTE(list[value] x, list[value] y, list[value] z) = (x <= y && y <= z) ==> x <= z; | ||
|
||
// sets are ordered via sub-set relation | ||
test bool subsetOrdering1(set[value] x, set[value] y) = x <= x + y; | ||
test bool subsetOrdering2(set[value] x, set[value] y) = (x <= y) <==> (x == {} || all(e <- x, e in y)); | ||
|
||
// sets are partially ordered | ||
test bool setReflexLTE1(set[value] x) = (x <= x); | ||
test bool setAntiSymmetricLTE1(set[value] x, set[value] y) = (x <= y && y <= x) ==> (x == y); | ||
test bool setTransLTE1(set[value] x, set[value] y, set[value] z) = (x <= y && y <= z) ==> x <= z; | ||
|
||
// map are ordered via sub-map relation | ||
|
||
/*TODO: | ||
java.lang.Exception: Test submapOrdering1 failed due to | ||
io.usethesource.vallang.type.IntegerType cannot be cast to io.usethesource.vallang.util.TrieMap$CompactMapNode | ||
Actual parameters: | ||
map[value, value] =>(true:("":[])) | ||
map[value, value] =>("":0.5741726876359169,true:-405555075,639525932r165438573:233378841r1234953134,"M"(true,|tmp:///|):true,|tmp:///|:|tmp:///g7/J|) | ||
*/ | ||
test bool submapOrdering1(map[value,value] x, map[value,value] y) = x <= y + x; // remember map join is not commutative | ||
|
||
/*TODO: | ||
java.lang.Exception: failed for arguments: (true:"",-1185257414:"1sn"({""()},"冖资"(|tmp:///|),-304421973r46873778,["R7jZ"()])) | ||
(true:"",$3632-03-24T14:03:39.476+01:00$:["0Xo","",""],|tmp:///|:$2015-08-06T08:23:51.810+01:00$,|tmp:///R66k|:<"h7"()>) | ||
import ParseTree; | ||
|
||
start syntax A = "a"; | ||
layout WS = [\ \t\n\r]*; | ||
|
||
test bool saveAndRestoreParser() { | ||
storeParsers(#start[A], |memory://test-tmp/parsers.jar|); | ||
p = loadParsers(|memory://test-tmp/parsers.jar|); | ||
|
||
x = p(type(\start(sort("A")), ()), "a", |origin:///|); | ||
y = parse(#start[A], "a", |origin:///|); | ||
|
||
return x == y; // (I) | ||
} | ||
|
||
Tree f(Symbol sym, map[Symbol, Production] rules, str input) | ||
= ParseTree::parse(type(sym, rules), input, |todo:///|); // (II) | ||
|
||
/* A catch22: | ||
How to assign a type to a reified type of the form type(...)? | ||
My current solution: compute the most specific type for the first argument of type(...). | ||
This assigns type Symbol to x | ||
This accepts (II) but fails for (I) with the message "Comparison not defined on `Symbol` and `start[A]`" | ||
An alternative solution (suggested by comments Jurgen added in CollectExpression): always return value() | ||
This accepts (I) but fails for (II) with the message: | ||
"Cannot instantiate formal parameter type `type[&T \<: Tree]`: Type parameter `T` should be less than `Tree`, but is bound to `value`" | ||
The question: how to assign a type to type(...) that accepts both these legal cases. | ||
*/ | ||
test bool submapOrdering2(map[value,value]x, map[value,value] y) = (x <= y) <==> (x == () || all(e <- x, e in y, eq(y[e], x[e]))); | ||
|
||
// maps are partially ordered | ||
test bool setReflexLTE2(map[value,value] x) = (x <= x); | ||
test bool setAntiSymmetricLTE2(map[value,value] x, map[value,value] y) = (x <= y && y <= x) ==> (x == y); | ||
test bool setTransLTE2(map[value,value] x, map[value,value] y, map[value,value] z) = (x <= y && y <= z) ==> x <= z; | ||
|
||
// locs are partially ordered | ||
test bool locReflexLTE(loc x) = (x <= x); | ||
test bool locAntiSymmetricLTE(loc x, loc y) = (x <= y && y <= x) ==> (x == y); | ||
test bool locTransLTE(loc x, loc y, loc z) = (x <= y && y <= z) ==> x <= z; | ||
|
||
// conversions | ||
test bool intToReal1(int i) = i == toReal(i); | ||
test bool ratToReal1(rat r) = r == toReal(r); | ||
test bool intToReal2(int i) = i <= toReal(i); | ||
test bool ratToReal2(rat r) = r <= toReal(r); | ||
test bool intToReal3(int i) = toReal(i) >= i; | ||
test bool ratToReal3(rat r) = toReal(r) >= r; | ||
test bool lessIntReal(int i) = !(i < toReal(i)); | ||
test bool lessRatReal(int i) = !(i < toReal(i)); | ||
|
||
// set containment | ||
test bool differentElements(int i) = size({i, toReal(i), toRat(i,1)}) == 3; // yes, really 3. | ||
test bool differentElement2(int i, rat r) = i == r ==> size({i,r}) == 2; // yes, really 2. | ||
test bool differentElement3(int i, real r) = i == r ==> size({i,r}) == 2; // yes, really 2. | ||
|
||
// map keys | ||
test bool differentKeys1(int i,real r) = ((i:10,r:20)[toReal(i)]?0) == 0; | ||
test bool differentKeys2(int i,rat r) = ((i:10,r:20)[toRat(i,1)]?0) == 0; | ||
test bool differentKeys3(int i) = size((i:10) + (toRat(i,1):20) + (toReal(i):30)) == 3; | ||
|
||
// == vs eq | ||
test bool eqImpliesEquals(value x, value y) = eq(x,y) ==> (x == y); | ||
test bool nonComparabilityImpliesNonEq(value x, value y) = !comparable(typeOf(x),typeOf(y)) ==> !eq(x,y); | ||
test bool comparabilityImpliesEquivalence(value x, value y) = comparable(typeOf(x),typeOf(y)) ==> (eq(x,y) <==> x == y); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 4 additions & 25 deletions
29
src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,8 @@ | ||
@bootstrapParser | ||
module lang::rascalcore::compile::Examples::Tst4 | ||
|
||
import Exception; | ||
import ParseTree; | ||
//import lang::rascalcore::check::AType; | ||
|
||
value main(){ //test bool higherOrderFunctionCompatibility1() { | ||
// the parameter function is specific to int | ||
int parameter(int _) { return 0; } | ||
|
||
// the higher order function expects to call the | ||
// parameter function with other things too | ||
int hof(int (value) p, value i) { return p(i); } | ||
|
||
// still this is ok, since functions in Rascal | ||
// are partial. This call should simply succeed: | ||
if (hof(parameter, 1) != 0) { | ||
return false; | ||
} | ||
|
||
// but the next call produces a CallFailed, since | ||
// the parameter function is not defined on strings: | ||
try { | ||
// statically allowed! but dynamically failing | ||
hof(parameter, "string"); | ||
return false; | ||
} | ||
catch CallFailed(_): | ||
return true; | ||
} | ||
//value main() = asubtype(\start(aadt("A",[],contextFreeSyntax())), aadt("Symbol",[],dataSyntax())); | ||
value main() = subtype(\start(sort("A")), adt("Symbol",[])); |
Oops, something went wrong.