object Protocol { /* markers for inlined messages */
val Loading_Theory_Marker = Protocol_Message.Marker("loading_theory") val Meta_Info_Marker = Protocol_Message.Marker("meta_info") val Command_Timing_Marker = Protocol_Message.Marker("command_timing") val Theory_Timing_Marker = Protocol_Message.Marker("theory_timing") val Session_Timing_Marker = Protocol_Message.Marker("session_timing") val ML_Statistics_Marker = Protocol_Message.Marker("ML_statistics") val Task_Statistics_Marker = Protocol_Message.Marker("task_statistics") val Error_Message_Marker = Protocol_Message.Marker("error_message")
/* batch build */
object Loading_Theory { def unapply(props: Properties.T): Option[(Document.Node.Name, Document_ID.Exec, Int)] = for {
theory <- Markup.Name.unapply(props)
commands <- Markup.Commands.unapply(props)
file <- Position.File.unapply(props) if Path.is_wellformed(file)
id <- Position.Id.unapply(props)
} yield (Document.Node.Name(file, theory = theory), id, commands)
}
def sendback_snippets(xml: XML.Body): List[(String, Properties.T)] = { var seen = Set.empty[(String, Properties.T)] val result = new mutable.ListBuffer[(String, Properties.T)]
@tailrec def traverse(body: XML.Body): Unit =
body match { case XML.Elem(Markup(Markup.SENDBACK, props), body1) :: body2 => val entry = (XML.content(body1), props) if (!seen(entry)) {
seen += entry
result += entry
}
traverse(body2) case XML.Wrapped_Elem(_, _, body1) :: body2 => traverse(body1 ::: body2) case XML.Elem(_, body1) :: body2 => traverse(body1 ::: body2) case XML.Text(_) :: body2 => traverse(body2) case Nil =>
}
traverse(xml)
result.toList
}
/* breakpoints */
object ML_Breakpoint { def unapply(tree: XML.Tree): Option[Long] =
tree match { case XML.Elem(Markup(Markup.ML_BREAKPOINT, Markup.Serial(breakpoint)), _) => Some(breakpoint) case _ => None
}
}
/* dialogs */
object Dialog_Args { def unapply(props: Properties.T): Option[(Document_ID.Generic, Long, String)] =
(props, props, props) match { case (Position.Id(id), Markup.Serial(serial), Markup.Result(result)) =>
Some((id, serial, result)) case _ => None
}
}
object Dialog { def unapply(tree: XML.Tree): Option[(Document_ID.Generic, Long, String)] =
tree match { case XML.Elem(Markup(Markup.DIALOG, Dialog_Args(id, serial, result)), _) =>
Some((id, serial, result)) case _ => None
}
}
def define_command(resources: Resources, command: Command): Unit = { val (a, b, c, d, e, rest) = encode_command(resources, command)
protocol_command_args("Document.define_command", a :: b :: c :: d :: e :: rest)
}
def define_commands(resources: Resources, commands: List[Command]): Unit =
protocol_command_args("Document.define_commands",
commands.map { command => import XML.Encode._ val (a, b, c, d, e, rest) = encode_command(resources, command)
pair(self, pair(self, pair(self, pair(self, pair(self, list(self))))))(
a, (b, (c, (d, (e, rest)))))
})
def define_commands_bulk(resources: Resources, commands: List[Command]): Unit = { val (irregular, regular) = commands.partition(command => YXML.detect(command.source))
irregular.foreach(define_command(resources, _))
regular match { case Nil => case List(command) => define_command(resources, command) case _ => define_commands(resources, regular)
}
}
/* execution */
def discontinue_execution(): Unit =
protocol_command("Document.discontinue_execution")
def cancel_exec(id: Document_ID.Exec): Unit =
protocol_command("Document.cancel_exec", Document_ID.encode(id))
/* document versions */
def update(
old_id: Document_ID.Version,
new_id: Document_ID.Version,
edits: List[Document.Edit_Command],
consolidate: List[Document.Node.Name]
): Unit = { val consolidate_xml = { import XML.Encode._; list(string)(consolidate.map(_.node)) } val edits_xml = { import XML.Encode._
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.