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
16 changes: 11 additions & 5 deletions kore/src/main/scala/org/kframework/parser/kore/Default.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ object implementation {

case class StringLiteral(str: String) extends i.StringLiteral

case class SortVariable(name: String) extends i.SortVariable
case class SortVariable(name: String) extends i.SortVariable {
override def toString = name
}

case class CompoundSort(ctr: String, params: Seq[i.Sort]) extends i.CompoundSort
case class CompoundSort(ctr: String, params: Seq[i.Sort]) extends i.CompoundSort {
override def toString = ctr + "{" + params.map(_.toString).mkString(", ") + "}"
}

case class SymbolOrAlias(ctr: String, params: Seq[i.Sort]) extends i.SymbolOrAlias
case class SymbolOrAlias(ctr: String, params: Seq[i.Sort]) extends i.SymbolOrAlias {
override def toString = ctr + "{" + params.map(_.toString).mkString(", ") + "}"
}

case class Symbol(ctr: String, params: Seq[i.Sort]) extends i.Symbol

Expand Down Expand Up @@ -125,13 +131,13 @@ object implementation {

// def Next(s: i.Sort, _1: i.Pattern): i.Pattern = d.Next(s, _1)

def Rewrites(s: i.Sort, _1: i.Pattern, _2: i.Pattern): i.Pattern = d.Rewrites(s, _1, _2)
def Rewrites(s: i.Sort, _1: i.Pattern, _2: i.Pattern): i.Rewrites = d.Rewrites(s, _1, _2)

def Ceil(s: i.Sort, rs: i.Sort, p: Pattern): i.Pattern = d.Ceil(s, rs, p)

def Floor(s: i.Sort, rs: i.Sort, p: Pattern): i.Pattern = d.Floor(s, rs, p)

def Equals(s: i.Sort, rs: i.Sort, _1: i.Pattern, _2: i.Pattern): i.Pattern = d.Equals(s, rs, _1, _2)
def Equals(s: i.Sort, rs: i.Sort, _1: i.Pattern, _2: i.Pattern): i.Equals = d.Equals(s, rs, _1, _2)

def Mem(s: i.Sort, rs: i.Sort, p: i.Pattern, q: i.Pattern): i.Pattern = d.Mem(s, rs, p, q)

Expand Down
39 changes: 23 additions & 16 deletions kore/src/main/scala/org/kframework/parser/kore/Interface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ object SortDeclaration {
= Some(arg.params, arg.sort, arg.att)
}

trait HookSortDeclaration extends Declaration {
def params: Seq[SortVariable]

def sort: Sort

def att: Attributes
trait HookSortDeclaration extends SortDeclaration {
}

object HookSortDeclaration {
Expand All @@ -75,14 +70,7 @@ object SymbolDeclaration {
= Some(arg.symbol, arg.argSorts, arg.returnSort, arg.att)
}

trait HookSymbolDeclaration extends Declaration {
def symbol: Symbol

def argSorts: Seq[Sort]

def returnSort: Sort

def att: Attributes
trait HookSymbolDeclaration extends SymbolDeclaration {
}

object HookSymbolDeclaration {
Expand Down Expand Up @@ -287,33 +275,52 @@ object Floor {
// def unapply(arg: Next): Option[(Sort, Pattern)] = Some(arg.s, arg._1)
// }

trait GeneralizedRewrite {
def sort: Sort
def getLeftHandSide: Seq[Pattern]
def getRightHandSide: Pattern
}

/**
* \rewrites(P, Q) is defined as a predicate pattern floor(P implies Q)
* Therefore a rewrites-to pattern is parametric on two sorts.
* One is the sort of patterns P and Q;
* The other is the sort of the context.
*/
trait Rewrites extends Pattern {
trait Rewrites extends Pattern with GeneralizedRewrite {
def s: Sort // the sort of the two patterns P and Q

def sort = s

def _1: Pattern

def _2: Pattern

def getLeftHandSide = Seq(_1)
def getRightHandSide = _2
}

object Rewrites {
def unapply(arg: Rewrites): Option[(Sort, Pattern, Pattern)] =
Some(arg.s, arg._1, arg._2)
}

trait Equals extends Pattern {
trait Equals extends Pattern with GeneralizedRewrite {
def s: Sort // the sort of the two patterns that are being compared

def rs: Sort // the sort of the context where the equality pattern is being placed

def sort = rs

def _1: Pattern

def _2: Pattern

def getLeftHandSide = _1 match {
case Application(_, ps) => ps
}

def getRightHandSide = _2
}

object Equals {
Expand Down