Skip to content

Commit

Permalink
Added missing cases for overloadedAType for alub and aglb.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Jun 22, 2024
1 parent cfdc633 commit 1fb3e2c
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/AType.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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|,
Expand Down
Original file line number Diff line number Diff line change
@@ -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) = [];

Original file line number Diff line number Diff line change
@@ -1,5 +1,152 @@
module lang::rascalcore::compile::Examples::Tst4

value main() {
return { /abc/ } := { "abc" };
}
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()))
);

0 comments on commit 1fb3e2c

Please sign in to comment.