--- a/progs/fun/fun_parser.sc Fri Nov 22 12:42:07 2024 +0000
+++ b/progs/fun/fun_parser.sc Fri Nov 29 18:58:18 2024 +0000
@@ -10,15 +10,14 @@
// this will generate a parse-tree from a list
// of tokens
-//> using toolkit 0.5.0
-// > using file fun_tokens.scala
+import $file.fun_tokens, fun_tokens._
import scala.language.implicitConversions
import scala.language.reflectiveCalls
-//import $file.fun_tokens, fun_tokens._
+
// Parser combinators
@@ -26,16 +25,6 @@
//
type IsSeq[I] = I => Seq[?]
-/*
-abstract class Parser[I, T](using is: I => Seq[_]) {
- def parse(in: I): Set[(T, I)]
-
- def parse_all(in: I) : Set[T] =
- for ((hd, tl) <- parse(in);
- if is(tl).isEmpty) yield hd
-}
-*/
-
abstract class Parser[I, T](using is: I => Seq[?]) {
def parse(ts: I): Set[(T, I)]
@@ -179,17 +168,11 @@
// Reading tokens and Writing parse trees
-// pre-2.5.0 ammonite
-// import ammonite.ops._
-
-// post 2.5.0 ammonite
-// import os._
-
def parse_tks(tks: List[Token]) : List[Decl] =
Prog.parse_single(tks)
-//@doc("Parses a file.")
-//@main
+
+@main
def main(fname: String) : Unit = {
val tks = tokenise(os.read(os.pwd / fname))
println(parse_tks(tks))