Skip to content
Snippets Groups Projects
Commit 4f601d01 authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

DepthBound aspect

parent 12384b45
No related branches found
No related tags found
No related merge requests found
/* Copyright 2009-2016 EPFL, Lausanne */
package leon
package grammars
package aspects
/** Limits a grammar by depth */
case class DepthBound(depth: Int) extends Aspect {
require(depth >= 0)
def asString(implicit ctx: LeonContext): String = s"D$depth"
def applyTo(l: Label, ps: Seq[Production])(implicit ctx: LeonContext) = {
if (depth == 0) Nil
else if (depth == 1) ps.filter(_.isTerminal)
else {
ps map { prod =>
prod.copy(subTrees = prod.subTrees.map(_.withAspect(DepthBound(depth - 1))))
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment