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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>typepal</artifactId>
<version>0.17.0-BOOT2</version>
<version>0.17.0-RC3</version>
<!-- <scope>provided</scope> for shade plugin it can't be provided. At least the rascal dependency in typepal should be provided -->
<scope>compile</scope>
</dependency>
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
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