-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/scala/org/kframework/backend/skala/backendImplicits.scala
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.kframework.backend.skala | ||
import org.kframework.kore.extended.implicits._ | ||
import org.kframework.kore | ||
import org.kframework.kore.implementation.{DefaultBuilders => db} | ||
|
||
/** | ||
* Implicits that add to Extended Kore | ||
*/ | ||
object backendImplicits { | ||
implicit class ModuleWithSubsorting(m: kore.Module)(implicit definiton: kore.Definition) { | ||
private lazy val subsortRelations: Set[(kore.Sort, kore.Sort)] = m.allSentences.collect({ | ||
case kore.SymbolDeclaration(startSort, _, Seq(endSort), att) if att.findSymbol(db.Symbol("klabel")).isEmpty => (endSort, startSort) | ||
}).toSet | ||
|
||
lazy val subsorts: POSet[kore.Sort] = POSet(subsortRelations) | ||
|
||
lazy val sortsFor: Map[kore.Symbol, Set[kore.Sort]] = m.allSentences.collect({ | ||
case kore.SymbolDeclaration(s, sym, _, _) => (sym, s) | ||
}).groupBy(_._1).mapValues(_.map(_._2).toSet) | ||
} | ||
} |