Skip to content

Instantly share code, notes, and snippets.

@braised-babbage
braised-babbage / Parse.scala
Created April 23, 2018 19:22
Recursive Descent Parser
package example
sealed trait ArithExpr
case class Number(value: Double) extends ArithExpr
case class BinaryOp(op: String, lhs: ArithExpr, rhs: ArithExpr) extends ArithExpr
/** Parse an arithmetic expression from a list of tokens, using recursive descent.
*
* This is bad scala style (e.g. I should use options). Right now,