src/Pure/Thy/sessions.scala
changeset 75995 627a08637c35
parent 75987 ff2e67d73592
child 75996 633f74e679f5
equal deleted inserted replaced
75994:f0ea03be7ceb 75995:627a08637c35
  1016 
  1016 
  1017   def parse_root_entries(path: Path): List[Session_Entry] =
  1017   def parse_root_entries(path: Path): List[Session_Entry] =
  1018     for (entry <- Parsers.parse_root(path) if entry.isInstanceOf[Session_Entry])
  1018     for (entry <- Parsers.parse_root(path) if entry.isInstanceOf[Session_Entry])
  1019     yield entry.asInstanceOf[Session_Entry]
  1019     yield entry.asInstanceOf[Session_Entry]
  1020 
  1020 
  1021   def read_root(
       
  1022     options: Options,
       
  1023     select: Boolean,
       
  1024     path: Path,
       
  1025     chapter_defs: Chapter_Defs
       
  1026   ): (List[Info], Chapter_Defs) = {
       
  1027     var chapter_defs1 = chapter_defs
       
  1028     var entry_chapter = UNSORTED
       
  1029     val infos = new mutable.ListBuffer[Info]
       
  1030     parse_root(path).foreach {
       
  1031       case ch_def: Chapter_Def => chapter_defs1 += ch_def
       
  1032       case entry: Chapter_Entry => entry_chapter = entry.name
       
  1033       case entry: Session_Entry =>
       
  1034         infos += make_info(options, select, path.dir, entry_chapter, entry)
       
  1035     }
       
  1036     (infos.toList, chapter_defs1)
       
  1037   }
       
  1038 
       
  1039   def parse_roots(roots: Path): List[String] = {
  1021   def parse_roots(roots: Path): List[String] = {
  1040     for {
  1022     for {
  1041       line <- split_lines(File.read(roots))
  1023       line <- split_lines(File.read(roots))
  1042       if !(line == "" || line.startsWith("#"))
  1024       if !(line == "" || line.startsWith("#"))
  1043     } yield line
  1025     } yield line
  1106           }
  1088           }
  1107       }.toList.map(_._2)
  1089       }.toList.map(_._2)
  1108 
  1090 
  1109     val (chapter_defs, info_roots) = {
  1091     val (chapter_defs, info_roots) = {
  1110       var chapter_defs = Chapter_Defs.empty
  1092       var chapter_defs = Chapter_Defs.empty
  1111       val result = new mutable.ListBuffer[Info]
  1093       val info_roots = new mutable.ListBuffer[Info]
  1112       for { (select, path) <- unique_roots } {
  1094 
  1113         val (infos, chapter_defs1) = read_root(options, select, path, chapter_defs)
  1095       for ((select, path) <- unique_roots) {
  1114         chapter_defs = chapter_defs1
  1096         var entry_chapter = UNSORTED
  1115         result ++= infos
  1097         parse_root(path).foreach {
  1116       }
  1098           case entry: Chapter_Def => chapter_defs += entry
  1117       (chapter_defs, result.toList)
  1099           case entry: Chapter_Entry => entry_chapter = entry.name
       
  1100           case entry: Session_Entry =>
       
  1101             info_roots += make_info(options, select, path.dir, entry_chapter, entry)
       
  1102         }
       
  1103       }
       
  1104       (chapter_defs, info_roots.toList)
  1118     }
  1105     }
  1119 
  1106 
  1120     Structure.make(chapter_defs, info_roots ::: infos)
  1107     Structure.make(chapter_defs, info_roots ::: infos)
  1121   }
  1108   }
  1122 
  1109