progs/fun/fun_parser.sc
changeset 961 c0600f8b6427
parent 955 47acfd7f9096
child 975 ae5c03560d4d
--- a/progs/fun/fun_parser.sc	Wed May 29 13:25:30 2024 +0100
+++ b/progs/fun/fun_parser.sc	Thu Sep 19 15:47:33 2024 +0100
@@ -10,16 +10,21 @@
 // this will generate a parse-tree from a list
 // of tokens
 
+//> using toolkit 0.5.0
+// > using file fun_tokens.scala
+
+
 import scala.language.implicitConversions    
 import scala.language.reflectiveCalls
 
-import $file.fun_tokens, fun_tokens._ 
+
+//import $file.fun_tokens, fun_tokens._ 
 
 
 // Parser combinators
 //    type parameter I needs to be of Seq-type
 //
-type IsSeq[I] = I => Seq[_]
+type IsSeq[I] = I => Seq[?]
 
 /*
 abstract class Parser[I, T](using is: I => Seq[_])  {
@@ -32,7 +37,7 @@
 */
 
 
-abstract class Parser[I, T](using is: I => Seq[_]) {
+abstract class Parser[I, T](using is: I => Seq[?]) {
   def parse(ts: I): Set[(T, I)]
 
   def parse_single(ts: I) : T = 
@@ -76,7 +81,7 @@
   def map[S](f: => T => S) = new MapParser[I, T, S](p, f)
 }
 
-def ListParser[I, T, S](p: => Parser[I, T], q: => Parser[I, S])(using is: I => Seq[_]): Parser[I, List[T]] = {
+def ListParser[I, T, S](p: => Parser[I, T], q: => Parser[I, S])(using is: I => Seq[?]): Parser[I, List[T]] = {
   (p ~ q ~ ListParser(p, q)).map{ case (x:T) ~ (y:S) ~ (z:List[T]) => x :: z } ||
   (p.map[List[T]]{s => List(s)})
 }
@@ -184,7 +189,7 @@
   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))