Skip to content

Commit

Permalink
mul not working
Browse files Browse the repository at this point in the history
  • Loading branch information
erikerlandson committed Mar 5, 2023
1 parent ffc6532 commit b1fd7d2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions parser/src/main/scala/coulomb/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ object standard:
object infra:
import _root_.cats.parse.*

val ws: Parser[Unit] = Parser.charIn(" \t\r\n").void
val ws0: Parser0[Unit] = ws.rep0.void

def unit(named: Parser[RuntimeUnit]): Parser[RuntimeUnit] =
Parser.recursive[RuntimeUnit] { recurse =>
val sub: Parser[RuntimeUnit] = recurse.between(Parser.char('(') <* ws0, ws0 *> Parser.char(')'))
val mul: Parser[RuntimeUnit] =
((recurse <* Parser.char('*').soft.surroundedBy(ws0)).soft ~ recurse).map { case (lhs, rhs) =>
RuntimeUnit.Mul(lhs, rhs)
}
Parser.oneOf(named :: sub :: mul :: Nil)
}

def named(unames: Map[String, String], pnames: Set[String]): Parser[RuntimeUnit] =
// unames is never empty by construction
val unit = strset(unames.keySet).map { name =>
Expand Down

0 comments on commit b1fd7d2

Please sign in to comment.