Skip to content

The latest state of expr_parser #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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 Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ object Node:

require(
results.size == 1,
s"token(s) not found ${(tok +: toks).map(_.name).mkString(", ")}"
s"token(s) not found ${(tok +: toks).map(_.name).mkString(", ")}, in ${this.toShortString()}"
)
results.head

Expand Down
7 changes: 4 additions & 3 deletions PassSeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import dsl.*
transparent trait PassSeq:
def inputWellformed: Wellformed
final def outputWellformed: Wellformed =
assert(entriesSealed)
allPasses // compute allPasses, needed to enforce complete initialization
entries.last.wellformed

private val entries = mutable.ListBuffer.empty[PassSeq.Entry]
private var entriesSealed = false

protected def prevWellformed(using BuildCtx): Wellformed =
require(entries.nonEmpty, "there is no previous Wellformed")
entries.last.wellformed
if entries.isEmpty
then inputWellformed
else entries.last.wellformed

protected object wellformed:
def :=(using ctx: BuildCtx)(wellformed: Wellformed): Unit =
Expand Down
10 changes: 10 additions & 0 deletions Wellformed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,15 @@ object Wellformed:
s"$token's shape is not appropriate for adding cases ($shape)"
)

def deleteShape(): Unit =
token match
case Node.Top =>
require(topShapeOpt.nonEmpty)
topShapeOpt = None
case token: Token =>
require(assigns.contains(token))
assigns.remove(token)

def importFrom(wf2: Wellformed): Unit =
def fillFromShape(shape: Shape): Unit =
shape match
Expand All @@ -550,6 +559,7 @@ object Wellformed:
topShapeOpt = Some(wf2.topShape)
fillFromShape(wf2.topShape)
case token: Token => fillFromTokenOrEmbed(token)
end importFrom

private[Wellformed] def build(): Wellformed =
require(topShapeOpt.nonEmpty)
Expand Down
Loading