From 1fb3e2c37a4e8037566600873ea386292d52a08d Mon Sep 17 00:00:00 2001 From: paulklint Date: Sun, 23 Jun 2024 01:10:06 +0200 Subject: [PATCH] Added missing cases for overloadedAType for alub and aglb. --- .../library/lang/rascalcore/check/AType.rsc | 13 ++ .../library/lang/rascalcore/check/Checker.rsc | 4 +- .../lang/rascalcore/compile/Examples/Tst3.rsc | 28 +++- .../lang/rascalcore/compile/Examples/Tst4.rsc | 153 +++++++++++++++++- 4 files changed, 189 insertions(+), 9 deletions(-) diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/AType.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/AType.rsc index e828b423..6cb8e73e 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/AType.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/AType.rsc @@ -514,6 +514,13 @@ default AType alub(AType s, AType t) : avalue(); AType alub(atypeList(ts1), atypeList(ts2)) = atypeList(alubList(ts1, ts2)); + +AType alub(overloadedAType(overloads), AType t2) + = isEmpty(overloads) ? t2 : alub((avalue() | aglb(it, tp) | <_, _, tp> <- overloads), t2); + +AType alub(AType t1, overloadedAType(overloads)) + = isEmpty(overloads) ? t1 : alub(t1, (avalue() | aglb(it, tp) | <_, _, tp> <- overloads)); + AType alub(avalue(), AType t) = avalue(); AType alub(AType s, avalue()) = avalue(); AType alub(avoid(), AType t) = t; @@ -699,6 +706,12 @@ public AType aglb(arel(AType s), aset(AType t)) = aset(aglb(atuple(s), t)); AType aglb(arel(atypeList(list[AType] l)), arel(atypeList(list[AType] r))) = size(l) == size(r) ? arel(atypeList(aglbList(l, r))) : aset(avalue()); +AType aglb(overloadedAType(overloads), AType t2) + = isEmpty(overloads) ? t2 : aglb((avoid() | alub(it, tp) | <_, _, tp> <- overloads), t2); + +AType aglb(AType t1, overloadedAType(overloads)) + = isEmpty(overloads) ? t1 : aglb(t1, (avoid() | alub(it, tp) | <_, _, tp> <- overloads)); + public AType aglb(alist(AType s), alist(AType t)) = alist(aglb(s, t)); public AType aglb(alist(AType s), alrel(AType t)) = alist(aglb(s,atuple(t))); public AType aglb(alrel(AType s), alist(AType t)) = alist(aglb(atuple(s), t)); diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc index f197433c..24a27d18 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc @@ -145,7 +145,9 @@ public PathConfig getRascalCorePathConfig() { //|project://rascal_eclipse/src/org/rascalmpl/eclipse/library|, |project://typepal/src|, |project://rascal-tutor/src|, - |project://flybytes/src| + |project://flybytes/src|, + //|project://rascal-lsp/src/main/| + |project://rascal-lsp/src/main/rascal/| ], bin = |project://rascal-core/target/test-classes|, generatedSources = |project://rascal-core/target/generated-test-sources|, diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst3.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst3.rsc index 1d034f54..e6467a8f 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst3.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst3.rsc @@ -1,8 +1,26 @@ module lang::rascalcore::compile::Examples::Tst3 -data Maybe[&A] - = nothing() - | just(&A val) - ; +syntax Program = ; -void loadClass( Maybe[loc] file=nothing()) {} +data Tree; + +@javaClass{org.rascalmpl.library.Prelude} +java &T (value input, loc origin) parser(type[&T] grammar); + +alias Parser = Tree (str /*input*/, loc /*origin*/); +alias Outliner = list[DocumentSymbol] (Tree /*input*/); +data DocumentSymbol; + +data LanguageService + = parser(Parser parser) + | outliner(Outliner outliner) + ; + +set[LanguageService] SL = { + outliner(picoOutliner), + parser(parser(#start[Program])) + + }; + +list[DocumentSymbol] picoOutliner(start[Program] _input) = []; + \ No newline at end of file diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc index 15b5bb1d..87c2a3a3 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc @@ -1,5 +1,152 @@ module lang::rascalcore::compile::Examples::Tst4 -value main() { - return { /abc/ } := { "abc" }; -} \ No newline at end of file +import lang::rascalcore::check::AType; +import lang::rascalcore::check::BasicRascalConfig; + +value a1() = alub( + overloadedAType({ + <|project://rascal-core/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst3.rsc|(399,6,<18,6>,<18,12>),constructorId(),acons( + aadt( + "LanguageService", + [], + dataSyntax()), + [afunc( + aadt( + "Tree", + [], + dataSyntax()), + [ + astr(), + aloc() + ], + [], + alabel="parser")], + [], + alabel="parser")>, + <|project://rascal-core/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst3.rsc|(121,101,<11,0>,<12,59>),functionId(),afunc( + afunc( + aparameter( + "T", + avalue(), + closed=true), + [ + avalue(), + aloc() + ], + []), + [areified( + aparameter( + "T", + avalue(), + closed=false), + alabel="grammar")], + [], + returnsViaAllPath=true, + abstractFingerprint=0, + alabel="parser")> + }), + + acons( + aadt( + "LanguageService", + [], + dataSyntax()), + [afunc( + alist(aadt( + "DocumentSymbol", + [], + dataSyntax())), + [aadt( + "Tree", + [], + dataSyntax())], + [], + alabel="outliner")], + [], + alabel="outliner") + ); + + + value a2() = alub( + + afunc( + afunc( + aparameter( + "T", + avalue(), + closed=true), + [ + avalue(), + aloc() + ], + []), + [areified( + aparameter( + "T", + avalue(), + closed=false), + alabel="grammar")], + [], + returnsViaAllPath=true, + abstractFingerprint=0, + alabel="parser") + , + + acons( + aadt( + "LanguageService", + [], + dataSyntax()), + [afunc( + alist(aadt( + "DocumentSymbol", + [], + dataSyntax())), + [aadt( + "Tree", + [], + dataSyntax())], + [], + alabel="outliner")], + []) +); + + +AType a3() = alub( + afunc( + aparameter( + "T", + avalue(), + closed=true), + [ + avalue(), + aloc() + ], + []) +, + + afunc( + alist(aadt( + "DocumentSymbol", + [], + dataSyntax())), + [aadt( + "Tree", + [], + dataSyntax())], + [], + alabel="outliner") +); + + +AType a4() = alub( + aparameter( + "T", + avalue(), + closed=true) + , + alist(aadt( + "DocumentSymbol", + [], + dataSyntax())) +); \ No newline at end of file