Skip to content
Merged
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
12 changes: 8 additions & 4 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
# git config blame.ignoreRevsFile .git-blame-ignore-revs

# indent fix for JSON
31b1031ade5d84f9c60e30d17da3b55e78d291fb
f5d0490e283e36e527821736b11f9b09163b67b6

# fixing tabs & spaces mixed
0d048e15683740b5c944be5333ec0680df825e47
23ec4b622bbe503ef013be5a458e45ae6fd89b97
200b0352084be9435c64aa60c550edd24a59131b
1b9801104c0e839e229c25f6a16b72a48e874594
97fc3b0739f848c8277f2b2c2aae3530afff37a6
a004c2604cef592975f60a572c4a03491b2f7971

# Revert and re-application of a merge commit
3d5369b35a00bddc085d722010baf329580b1c68
b277ae88b653f039b576717f8d9ecd56e5dbd2fe
1 change: 1 addition & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.css=UTF-8
encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.js=UTF-8
encoding//src/org/rascalmpl/library/experiments/vis2/lib/reset.css=UTF-8
encoding//src/org/rascalmpl/library/lang/rascal/tests/functionality/DataType.rsc=UTF-8
encoding//target/generated-resources=UTF-8
encoding//test/org/rascalmpl/test/data=UTF-8
encoding/<project>=UTF-8
encoding/META-INF=UTF-8
Expand Down
9 changes: 3 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@
</excludes>
</resource>
<resource>
<directory>.</directory>
<directory>META-INF</directory>
<targetPath>${project.build.outputDirectory}/META-INF</targetPath> <!-- this way of framing it works around issue in m2e -->
<filtering>false</filtering>
<includes>
<include>META-INF/RASCAL.MF</include>
<include>rascal-DEPENDENCIES.txt</include>
</includes>
</resource>
<resource>
<directory>${project.build.directory}/generated-resources</directory>
Expand Down Expand Up @@ -288,7 +285,7 @@
</goals>
<phase>package</phase>
<configuration>
<output>rascal-DEPENDENCIES.txt</output>
<output>${project.build.outputDirectory}/rascal-DEPENDENCIES.txt</output>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ public AType defsym2AType(Sym sym, SyntaxRole sr) {
}
}

public Tree defsym2IdTree(Sym sym) = top-down-break visit (sym) {
case lang::rascal::\syntax::Rascal::nonterminal(Nonterminal n): return n;
case \parametrized(Nonterminal n, _): return n;
case \start(Nonterminal n): return n;
default: {
iprintln(sym);
throw "defsym2IdTree, missed a case <sym>";
}
};

public list[AType] args2ATypes(Sym* args) {
return [sym2AType(s) | Sym s <- args];
}
Expand Down
21 changes: 17 additions & 4 deletions src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ str prettyAType(avalue()) = "value";
str prettyAType(aloc()) = "loc";
str prettyAType(adatetime()) = "datetime";
str prettyAType(alist(AType t)) = "list[<prettyAType(t)>]";
str prettyAType(abag(AType t)) = "bag[<prettyAType(t)>]";
str prettyAType(aset(AType t)) = "set[<prettyAType(t)>]";
str prettyAType(atuple(AType ts)) = "tuple[<prettyAType(ts)>]";
str prettyAType(amap(AType d, AType r)) = "map[<prettyAType(d)>, <prettyAType(r)>]";
Expand All @@ -92,6 +93,7 @@ str prettyAType(t: acons(AType adt, /*str consName,*/
list[AType] fields,
list[Keyword] kwFields))
= "<prettyAType(adt)>::<t.alabel>(<intercalate(", ", ["<prettyAType(ft)><ft.alabel? ? " <ft.alabel>" : "">" | ft <- fields])><isEmpty(kwFields) ? "" : ", "><intercalate(",", ["<prettyAType(kw.fieldType)> <kw.fieldName>=..." | Keyword kw <- kwFields])>)";
str prettyAType(aprod(AProduction production)) = prettyAType(production);

str prettyAType(amodule(str mname)) = "module <mname>";
str prettyAType(aparameter(str pn, AType t, closed=c)) =
Expand All @@ -108,7 +110,12 @@ str prettyAType(Keyword kw: kwField(fieldType, fieldName, _,defaultExp)) = "<pre
str prettyAType(Keyword kw: kwField(fieldType,fieldName, _)) = "<prettyAType(fieldType) <kw.fieldName> = ?";

// non-terminal symbols
str prettyAType(\prod(AType s, list[AType] fs/*, SyntaxRole _*/)) = "<prettyAType(s)> : (<intercalate(", ", [ prettyAType(f) | f <- fs ])>)"; //TODO others
str prettyAType(\prod(AType s, list[AType] fs/*, SyntaxRole _*/)) = "<prettyAType(s)> : <intercalate(" ", [ prettyAType(f) | f <- fs ])>";
str prettyAType(regular(AType s)) = prettyAType(s);
str prettyAType(priority(AType _s, list[AProduction] choices)) = "<intercalate(" \> ", [ prettyAType(a) | a <- choices ])>";
str prettyAType(associativity(AType _s, AAssociativity \assoc, set[AProduction] alternatives)) = "<prettyAssoc(\assoc)> ( <intercalate(" | ", [ prettyAType(a) | a <- alternatives ])> )";
str prettyAType(reference(AType s, str cons)) = ":<cons>";
str prettyAType(\achoice(AType s, set[AProduction] alternatives)) = "<intercalate(" | ", [ prettyAType(a) | a <- alternatives ])>";

// terminal symbols
str prettyAType(alit(str string)) = string;
Expand All @@ -124,9 +131,9 @@ str prettyAType(\aempty()) = "()";
str prettyAType(\opt(AType symbol)) = "<prettyAType(symbol)>?";
str prettyAType(\iter(AType symbol)) = "<prettyAType(symbol)>+";
str prettyAType(\iter-star(AType symbol)) = "<prettyAType(symbol)>*";
str prettyAType(\iter-seps(AType symbol, list[AType] separators)) = "{<prettyAType(symbol)> <intercalate(" ", [ "\"<prettyAType(sep)>\"" | sep <- separators, !isLayoutAType(sep) ])>}+";
str prettyAType(\iter-star-seps(AType symbol, list[AType] separators)) = "{<prettyAType(symbol)> <intercalate(" ", [ "\"<prettyAType(sep)>\"" | sep <- separators, !isLayoutAType(sep) ])>}*";
str prettyAType(\alt(set[AType] alternatives)) = "( <intercalate(" | ", [ prettyAType(a) | a <- alternatives ])> )" when size(alternatives) > 1;
str prettyAType(\iter-seps(AType symbol, list[AType] separators)) = size(seps) == 0 ? prettyAType(iter(symbol)) : "{<prettyAType(symbol)> <intercalate(" ", seps)>}+" when seps := [ "\"<prettyAType(sep)>\"" | sep <- separators, !isLayoutAType(sep) ];
str prettyAType(\iter-star-seps(AType symbol, list[AType] separators)) = size(seps) == 0 ? prettyAType(\iter-star(symbol)) : "{<prettyAType(symbol)> <intercalate(" ", seps)>}*" when seps := [ "\"<prettyAType(sep)>\"" | sep <- separators, !isLayoutAType(sep) ];
str prettyAType(\alt(set[AType] alternatives)) = "( <intercalate(" | ", [ prettyAType(a) | a <- alternatives ])> )" when size(alternatives) > 0;
str prettyAType(\seq(list[AType] sequence)) = "( <intercalate(" ", [ prettyAType(a) | a <- sequence ])> )" when size(sequence) > 1;
str prettyAType(\conditional(AType symbol, set[ACondition] conditions)) = "<prettyAType(symbol)> { <intercalate(" ", [ prettyPrintCond(cond) | cond <- conditions ])> }";
default str prettyAType(AType s) = "<s>"; //"<type(s,())>";
Expand All @@ -141,6 +148,12 @@ private str prettyPrintCond("a-begin-of-line"()) = "^";
private str prettyPrintCond("a-end-of-line"()) = "$";
private str prettyPrintCond("a-except"(str label)) = "!<label>";

private str prettyAssoc(\aleft()) = "left";
private str prettyAssoc(\aright()) = "right";
private str prettyAssoc(\aassoc()) = "assoc";
private str prettyAssoc(\a-non-assoc()) = "non-assoc";
private default str prettyAssoc(v) = "<v>";

@doc{Rascal abstract types to classic Symbols}
Symbol atype2symbol(AType tp){
//println("atype2symbol: <tp>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ list[ModuleMessages] check(list[loc] moduleLocs, RascalCompilerConfig compilerCo
list[ModuleMessages] reportModuleMessages(ModuleStatus ms){
moduleIds = domain(ms.moduleLocs);
messagesNoModule = {*ms.messages[mid] | MODID mid <- ms.messages, (mid notin moduleIds || mid notin ms.moduleLocs)} + toSet(ms.pathConfig.messages);
msgs = [ program(mid, (ms.messages[mid] ? {}) + messagesNoModule) | MODID mid <- moduleIds ];
msgs = [ program(ms.moduleLocs[mid], (ms.messages[mid] ? {}) + messagesNoModule) | MODID mid <- moduleIds ];
if(isEmpty(msgs) && !isEmpty(messagesNoModule)){
msgs = [ program(|unknown:///|, messagesNoModule) ];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void dataDeclaration(Tags tags, Declaration current, list[Variant] variants, Col
dt.md5 = normalizedMD5Hash(adtName, dataCounter);
dataCounter += 1;
if(!isEmpty(commonKeywordParameterList)) dt.commonKeywordFields = commonKeywordParameterList;
c.define("<userType.name>", dataId(), current, dt);
c.define(userType.name, dataId(), current, dt);

adtParentScope = c.getScope();
c.enterScope(current);
Expand Down Expand Up @@ -142,7 +142,7 @@ void collect(current:(Variant) `<Name name> ( <{TypeArg ","}* arguments> <Keywor
fieldType = ta.\type;
dt = defType([fieldType], makeFieldType(fieldName, fieldType));
dt.md5 = normalizedMD5Hash(currentModuleName, adtName, name, current);
c.define("<ta.name>", fieldId(), ta.name, dt);
c.define(ta.name, fieldId(), ta.name, dt);
}
}

Expand All @@ -153,13 +153,13 @@ void collect(current:(Variant) `<Name name> ( <{TypeArg ","}* arguments> <Keywor
kwfType = kwf.\type;
dt = defType([kwfType], makeKeywordFieldType(fieldName, kwf));
dt.md5 = normalizedMD5Hash(currentModuleName, adtName, dataCounter, name, consArity, kwfType, fieldName);
c.define("<kwf.name>", keywordFieldId(), kwf.name, dt);
c.define(kwf.name, keywordFieldId(), kwf.name, dt);
}

scope = c.getScope();
c.enterScope(current);
args = "<for(arg <- arguments){><arg is named ? "<arg.\type> <arg.name>" : "<arg>"> <}>";
c.defineInScope(adtParentScope, "<name>", constructorId(), name, defType(adt + formals + kwFormals + commonKwFormals,
c.defineInScope(adtParentScope, name, constructorId(), name, defType(adt + formals + kwFormals + commonKwFormals,
AType(Solver s){
adtType = s.getType(adt);
kwFormalTypes = [kwField(s.getType(kwf.\type)[alabel=prettyPrintName(kwf.name)], prettyPrintName(kwf.name), currentModuleName, kwf.expression) | kwf <- kwFormals /*+ commonKwFormals*/];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void collect(Module current, Collector c){
if(deprecated){
c.report(warning(header.name, "Deprecated module %v%v", mname, isEmpty(deprecationMessage) ? "" : ": <deprecationMessage>"));
}
c.define("<header.name>", moduleId(), current, defType(tmod));
c.define(header.name, moduleId(), current, defType(tmod));

c.push(key_current_module, mname);
c.enterScope(current);
Expand Down Expand Up @@ -192,7 +192,7 @@ void collect(current: (Declaration) `<Tags tags> <Visibility visibility> <Type v
if(isWildCard(vname)){
c.report(warning(var, "Variable names starting with `_` are deprecated; only allowed to suppress warning on unused variables"));
}
c.defineInScope(scope, "<var.name>", moduleVariableId(), var.name, dt);
c.defineInScope(scope, var.name, moduleVariableId(), var.name, dt);

if(var is initialized){
initial = var.initial;
Expand Down Expand Up @@ -238,7 +238,7 @@ void collect(current: (Declaration) `<Tags tags> <Visibility visibility> anno <T
// if(isWildCard(pname)){
// c.report(error(name, "Annotation names starting with `_` are deprecated; only allowed to suppress warning on unused variables"));
// }
c.define("<name>", annoId(), current, dt);
c.define(name, annoId(), current, dt);
collect(tags, annoType, onType, c);
}

Expand All @@ -253,7 +253,7 @@ void collect(current: (KeywordFormal) `<Type kwType> <Name name> = <Expression e
dt = defType([kwType], makeFieldType(kwformalName, kwType));
}
dt.md5 = normalizedMD5Hash(current);
c.define("<name>", keywordFormalId(), current, dt);
c.define(name, keywordFormalId(), current, dt);
c.calculate("keyword formal", current, [kwType, expression],
AType(Solver s){
expType = s.getType(expression);
Expand Down Expand Up @@ -432,7 +432,7 @@ void collect(current: (FunctionDeclaration) `<FunctionDeclaration decl>`, Collec
endUseBoundedTypeParameters(c);

dt.md5 = normalizedMD5Hash(md5Contrib);
c.defineInScope(parentScope, "<fname>", functionId(), current, dt);
c.defineInScope(parentScope, fname, functionId(), current, dt);
c.leaveScope(decl);
c.pop(currentFunction);
if(isEmpty(fstk)){
Expand Down Expand Up @@ -617,7 +617,7 @@ private tuple[set[str], rel[str,Type]] computeBoundsAndDefineTypeParams(Signatur
c.fact(tp, tp.name);
} else {
seenInParams += tpname;
c.define("<tp.name>", typeVarId(), tp.name,
c.define(tp.name, typeVarId(), tp.name,
defType(toList(typeParamBounds[tpname]), makeBoundDef(tp, typeParamBounds, closed=false)));
c.fact(tp, tp.name);
}
Expand Down Expand Up @@ -761,7 +761,7 @@ void collect (current: (Declaration) `<Tags tags> <Visibility visibility> alias
// c.report(warning(name, "Alias names starting with `_` are deprecated; only allowed to suppress warning on unused variables"));
// }

c.define("<name>", aliasId(), current, defType([base], AType(Solver s) { return s.getType(base); })[md5 = normalizedMD5Hash(md5Contrib4Tags(tags), visibility, name, base)]);
c.define(name, aliasId(), current, defType([base], AType(Solver s) { return s.getType(base); })[md5 = normalizedMD5Hash(md5Contrib4Tags(tags), visibility, name, base)]);
c.enterScope(current);
collect(tags, base, c);
c.leaveScope(current);
Expand All @@ -785,7 +785,7 @@ void collect (current: (Declaration) `<Tags tags> <Visibility visibility> alias
append tp.typeVar;
}

c.define("<name>", aliasId(), name, defType(typeParams + base, AType(Solver s){
c.define(name, aliasId(), name, defType(typeParams + base, AType(Solver s){
bindings = ();
params = for(int i <- index(typeParams)){
ptype = s.getType(typeParams[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void collect(current: (ConcreteHole) `\< <Sym symbol> <Name name> \>`, Collector
c.useLub(name, {formalOrPatternFormal(c)});
} else {
c.push(patternNames, uname);
c.define("<name>", formalOrPatternFormal(c), name, defLub([symbol], AType(Solver s) { return s.getType(symbol); }));
c.define(name, formalOrPatternFormal(c), name, defLub([symbol], AType(Solver s) { return s.getType(symbol); }));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ void collect(current: (Expression) `<Pattern pat> \<- <Expression expression>`,
} else
throw TypeUnavailable();

c.define("<name>", formalOrPatternFormal(c), name, defType(patType));
c.define(name, formalOrPatternFormal(c), name, defType(patType));
c.fact(pat, patType);
c.fact(current, abool());
return;
Expand Down
20 changes: 10 additions & 10 deletions src/org/rascalmpl/compiler/lang/rascalcore/check/CollectPattern.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void collect(RegExp regExp, Collector c){
if( (RegExp)`\<<Name name>\>` := regExp){
c.use(name, variableRoles);
} else if ((RegExp)`\<<Name name>:<NamedRegExp* regexps>\>` := regExp){
c.define("<name>", formalOrPatternFormal(c), name, defType(astr()));
c.define(name, formalOrPatternFormal(c), name, defType(astr()));
collect(name, regexps, c);
}
c.fact(regExp, astr());
Expand Down Expand Up @@ -109,7 +109,7 @@ void collect(current: (Pattern) `<Type tp> <Name name>`, Collector c){
}
}
}
c.define("<name>", formalOrPatternFormal(c), name, defType(tp));
c.define(name, formalOrPatternFormal(c), name, defType(tp));
} else {
c.fact(name, tp);
//c.calculate("variable <name>", name, [tp], AType(Solver s) { return s.getType(tp); });
Expand All @@ -129,7 +129,7 @@ void collectAsVarArg(current: (Pattern) `<Type tp> <Name name>`, Collector c){
});
} else {
c.push(patternNames, <uname, getLoc(name)>);
c.define("<name>", formalOrPatternFormal(c), name, defType([tp], AType(Solver s){
c.define(name, formalOrPatternFormal(c), name, defType([tp], AType(Solver s){
res = alist(s.getType(tp))[alabel=uname];
return res;
}));
Expand Down Expand Up @@ -158,15 +158,15 @@ void collect(current: (Pattern) `<QualifiedName name>`, Collector c){
if(!isEmpty(qualifier)) c.report(error(name, "Qualifier not allowed"));
if(isTopLevelParameter(c)){
c.fact(current, avalue(alabel=unescape(prettyPrintBaseName(name))));
c.define("<name.names[-1]>", formalId(), name, defLub([], AType(Solver _) { return avalue(alabel=unescape(prettyPrintBaseName(name))); }));
c.define(name.names[-1], formalId(), name, defLub([], AType(Solver _) { return avalue(alabel=unescape(prettyPrintBaseName(name))); }));
} else {
if(c.isAlreadyDefined(base, name)){
c.use(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId(), constructorId()});
c.report(info(name, "Pattern variable %q has been declared outside pattern and its value will be used, add explicit declaration here if you want a new variable", name));
} else {
tau = c.newTypeVar(name);
c.fact(name, tau); //<====
c.define("<name.names[-1]>", formalOrPatternFormal(c), name, defLub([], AType(Solver s) {
c.define(name.names[-1], formalOrPatternFormal(c), name, defLub([], AType(Solver s) {
return s.getType(tau)[alabel=unescape(prettyPrintBaseName(name))];
}));
}
Expand Down Expand Up @@ -223,7 +223,7 @@ void collectSplicePattern(Pattern current, Pattern argument, Collector c){
}
}

c.define("<argName>", formalOrPatternFormal(c), argName, defType([tp],
c.define(argName, formalOrPatternFormal(c), argName, defType([tp],
AType(Solver s){ return inSet ? aset(s.getType(tp)) : alist(s.getType(tp)); }));
} else {
c.calculate("typed anonymous variable in splice pattern", argName, [tp],
Expand All @@ -246,7 +246,7 @@ void collectSplicePattern(Pattern current, Pattern argument, Collector c){
if(isTopLevelParameter(c)){
c.fact(current, avalue());
if(!isEmpty(qualifier)) c.report(error(argName, "Qualifier not allowed"));
c.define("<argName.names[-1]>", formalId(), argName, defLub([], AType(Solver _) { return avalue(); }));
c.define(argName.names[-1], formalId(), argName, defLub([], AType(Solver _) { return avalue(); }));
} else {
if(c.isAlreadyDefined("<argName>", argName)) {
c.use(argName, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId()});
Expand All @@ -255,7 +255,7 @@ void collectSplicePattern(Pattern current, Pattern argument, Collector c){
tau = c.newTypeVar(current); // <== argName;
c.fact(current, tau); // <===
if(!isEmpty(qualifier)) c.report(error(argName, "Qualifier not allowed"));
c.define("<argName.names[-1]>", formalOrPatternFormal(c), argName,
c.define(argName.names[-1], formalOrPatternFormal(c), argName,
defLub([], AType(Solver s) {
return inSet ? makeSetType(s.getType(tau)) : makeListType(s.getType(tau));}));
}
Expand Down Expand Up @@ -320,7 +320,7 @@ void collect(current: (Pattern) `<Name name> : <Pattern pattern>`, Collector c){
} else {
c.push(patternNames, <uname, getLoc(name)>);
scope = c.getScope();
c.define("<name>", formalOrPatternFormal(c), name,
c.define(name, formalOrPatternFormal(c), name,
defLub([pattern], AType(Solver s) {
try{
return s.getType(pattern);
Expand Down Expand Up @@ -349,7 +349,7 @@ void collect(current: (Pattern) `<Type tp> <Name name> : <Pattern pattern>`, Col
}
}
}
c.define("<name>", formalOrPatternFormal(c), name, defType([tp], AType(Solver s){ return s.getType(tp); }));
c.define(name, formalOrPatternFormal(c), name, defType([tp], AType(Solver s){ return s.getType(tp); }));
}
}

Expand Down
Loading
Loading