519 else res |
519 else res |
520 } |
520 } |
521 } |
521 } |
522 |
522 |
523 |
523 |
|
524 /* inlined properties -- syntax similar to ML */ |
|
525 |
|
526 object Props |
|
527 { |
|
528 private val syntax = Outer_Syntax.empty + "," + "(" + ")" + "[" + "]" |
|
529 |
|
530 private object Parser extends Parse.Parser |
|
531 { |
|
532 def prop: Parser[Properties.Entry] = |
|
533 keyword("(") ~ string ~ keyword(",") ~ string ~ keyword(")") ^^ |
|
534 { case _ ~ x ~ _ ~ y ~ _ => (x, y) } |
|
535 def props: Parser[Properties.T] = |
|
536 keyword("[") ~> repsep(prop, keyword(",")) <~ keyword("]") |
|
537 } |
|
538 |
|
539 def parse(text: String): Properties.T = |
|
540 { |
|
541 Parser.parse_all(Parser.props, Token.reader(syntax.scan(text))) match { |
|
542 case Parser.Success(result, _) => result |
|
543 case bad => error(bad.toString) |
|
544 } |
|
545 } |
|
546 |
|
547 def parse_lines(prefix: String, lines: List[String]): List[Properties.T] = |
|
548 for (line <- lines; s <- Library.try_unprefix(prefix, line)) yield parse(s) |
|
549 |
|
550 def find_parse_line(prefix: String, lines: List[String]): Option[Properties.T] = |
|
551 lines.find(_.startsWith(prefix)).map(line => parse(line.substring(prefix.length))) |
|
552 } |
|
553 |
|
554 |
524 /* log files */ |
555 /* log files */ |
525 |
556 |
526 private val LOG = Path.explode("log") |
557 private val LOG = Path.explode("log") |
527 private def log(name: String): Path = LOG + Path.basic(name) |
558 private def log(name: String): Path = LOG + Path.basic(name) |
528 private def log_gz(name: String): Path = log(name).ext("gz") |
559 private def log_gz(name: String): Path = log(name).ext("gz") |
529 |
560 |
530 private val SESSION_PARENT_PATH = "\fSession.parent_path = " |
561 private val SESSION_PARENT_PATH = "\fSession.parent_path = " |
531 |
562 |
|
563 |
532 sealed case class Log_Info(stats: List[Properties.T], timing: Properties.T) |
564 sealed case class Log_Info(stats: List[Properties.T], timing: Properties.T) |
533 |
565 |
534 def parse_log(text: String): Log_Info = |
566 def parse_log(text: String): Log_Info = |
535 { |
567 { |
536 val lines = split_lines(text) |
568 val lines = split_lines(text) |
537 val stats = Properties.parse_lines("\fML_statistics = ", lines) |
569 val stats = Props.parse_lines("\fML_statistics = ", lines) |
538 val timing = Properties.find_parse_line("\fTiming = ", lines) getOrElse Nil |
570 val timing = Props.find_parse_line("\fTiming = ", lines) getOrElse Nil |
539 Log_Info(stats, timing) |
571 Log_Info(stats, timing) |
540 } |
572 } |
541 |
573 |
542 |
574 |
543 /* sources and heaps */ |
575 /* sources and heaps */ |