Skip to content

Commit

Permalink
Updates for Contingency changes
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jul 5, 2024
1 parent 4ac9d7f commit b9da660
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import dendrology.*, treeStyles.default

import scala.annotation.*

import contingency.*, errorHandlers.throwUnsafely
import contingency.*, strategies.throwUnsafely
import spectacular.*

import unsafeExceptions.canThrowAny
Expand All @@ -44,7 +44,7 @@ object Math:
val Close = complement(Open)
var index: Int = 1
def next(): Optional[Char] = if index >= text.length then Unset else text(index).also(index += 1)

given Show[Optional[Char]] =
case Unset => t""
case char => char.toString.tt
Expand All @@ -57,17 +57,17 @@ object Math:
case Leaf => recur(Op(recur(Leaf), t"", Leaf))
case Op(left, t"", right) => recur(Op(left, t"×", recur(right)))
case Op(left, node, right) => recur(Op(left, node, recur(right)))

case Close => current

case char: Char => current match
case Leaf => recur(Op(Op(Leaf, char.show, Leaf), t"", Leaf))
case Op(left, t"", right) => recur(Op(left, char.show, right))
case Op(left, node, Leaf) =>
if char.isLetter == node.head.isLetter then recur(Op(left, t"$node$char", Leaf))
else recur(Op(left, node, Op(Leaf, char.show, Leaf)))
case Op(left, node, right) => recur(Op(current, char.show, Leaf))

recur().also:
if index != text.length then ???

Expand Down Expand Up @@ -113,4 +113,4 @@ enum MathMl:
case Text()
case Tr()
case Under()
case UnderOver()
case UnderOver()

0 comments on commit b9da660

Please sign in to comment.