feat: implement parser #6

Merged
gk1623 merged 16 commits from parser into master 2025-02-02 13:45:26 +00:00
5 changed files with 30 additions and 65 deletions
Showing only changes of commit 302fecc91b - Show all commits

View File

@@ -1,20 +1,8 @@
package wacc
import parsley.{Parsley, Result}
import parsley.expr.chain
import lexer.implicits.implicitSymbol
import lexer.{integer, fully}
import parsley.Result
object parser {
def parse(input: String): Result[String, BigInt] = parser.parse(input)
private val parser = fully(expr)
private val add = (x: BigInt, y: BigInt) => x + y
private val sub = (x: BigInt, y: BigInt) => x - y
private lazy val expr: Parsley[BigInt] =
chain.left1(integer | "(" ~> expr <~ ")")(
("+" as add) | ("-" as sub)
)
private val parser = lexer.fully(???)
}