src/Doc/System/Server.thy
changeset 75161 95612f330c93
parent 74920 9a2958ec9e08
child 76987 4c275405faae
equal deleted inserted replaced
75160:d48998648281 75161:95612f330c93
    14   process}, @{tool console}, but this approach is inadequate for reactive
    14   process}, @{tool console}, but this approach is inadequate for reactive
    15   applications that require quick responses from the prover.
    15   applications that require quick responses from the prover.
    16 
    16 
    17   In contrast, the Isabelle server exposes Isabelle/Scala as a
    17   In contrast, the Isabelle server exposes Isabelle/Scala as a
    18   ``terminate-stay-resident'' application that manages multiple logic
    18   ``terminate-stay-resident'' application that manages multiple logic
    19   \<^emph>\<open>sessions\<close> and concurrent tasks to use \<^emph>\<open>theories\<close>. This provides an
    19   \<^emph>\<open>sessions\<close> and concurrent tasks to use \<^emph>\<open>theories\<close>. This is analogous to
    20   analogous to \<^ML>\<open>Thy_Info.use_theories\<close> in Isabelle/ML, but with full
    20   \<^ML>\<open>Thy_Info.use_theories\<close> in Isabelle/ML, with proper support for
    21   concurrency and Isabelle/PIDE markup.
    21   concurrent invocations.
    22 
    22 
    23   The client/server arrangement via TCP sockets also opens possibilities for
    23   The client/server arrangement via TCP sockets also opens possibilities for
    24   remote Isabelle services that are accessed by local applications, e.g.\ via
    24   remote Isabelle services that are accessed by local applications, e.g.\ via
    25   an SSH tunnel.
    25   an SSH tunnel.
    26 \<close>
    26 \<close>
   195 
   195 
   196     \<^item> A \<^emph>\<open>short message\<close> consists of a single line: it is a sequence of
   196     \<^item> A \<^emph>\<open>short message\<close> consists of a single line: it is a sequence of
   197     arbitrary bytes excluding CR (13) and LF (10), and terminated by CR-LF or
   197     arbitrary bytes excluding CR (13) and LF (10), and terminated by CR-LF or
   198     just LF.
   198     just LF.
   199 
   199 
   200     \<^item> A \<^emph>\<open>long message\<close> starts with a single that consists only of decimal
   200     \<^item> A \<^emph>\<open>long message\<close> starts with a single line consisting of decimal
   201     digits: these are interpreted as length of the subsequent block of
   201     digits: these are interpreted as length of the subsequent block of
   202     arbitrary bytes. A final line-terminator (as above) may be included here,
   202     arbitrary bytes. A final line-terminator (as above) may be included here,
   203     but is not required.
   203     but is not required.
   204 
   204 
   205   Messages in JSON format (see below) always fit on a single line, due to
   205   Messages in JSON format (see below) always fit on a single line, due to
   225 
   225 
   226 
   226 
   227 subsection \<open>Input and output messages \label{sec:input-output-messages}\<close>
   227 subsection \<open>Input and output messages \label{sec:input-output-messages}\<close>
   228 
   228 
   229 text \<open>
   229 text \<open>
   230   Server input and output messages have a uniform format as follows:
   230   The uniform format for server input and output messages is \<open>name argument\<close>,
   231 
   231   such that:
   232     \<^item> \<open>name argument\<close> such that:
       
   233 
   232 
   234     \<^item> \<open>name\<close> is the longest prefix consisting of ASCII letters, digits,
   233     \<^item> \<open>name\<close> is the longest prefix consisting of ASCII letters, digits,
   235     ``\<^verbatim>\<open>_\<close>'', ``\<^verbatim>\<open>.\<close>'',
   234     ``\<^verbatim>\<open>_\<close>'', ``\<^verbatim>\<open>.\<close>'',
   236 
   235 
   237     \<^item> the separator between \<open>name\<close> and \<open>argument\<close> is the longest possible
   236     \<^item> the separator between \<open>name\<close> and \<open>argument\<close> is the longest possible
   260     \<^item> empty argument (Scala type \<^verbatim>\<open>Unit\<close>)
   259     \<^item> empty argument (Scala type \<^verbatim>\<open>Unit\<close>)
   261     \<^item> XML element in YXML notation (Scala type \<^verbatim>\<open>XML.Elem\<close>)
   260     \<^item> XML element in YXML notation (Scala type \<^verbatim>\<open>XML.Elem\<close>)
   262     \<^item> JSON value (Scala type \<^verbatim>\<open>JSON.T\<close>)
   261     \<^item> JSON value (Scala type \<^verbatim>\<open>JSON.T\<close>)
   263 
   262 
   264   JSON values may consist of objects (records), arrays (lists), strings,
   263   JSON values may consist of objects (records), arrays (lists), strings,
   265   numbers, bools, null.\<^footnote>\<open>See also the official specification
   264   numbers, bools, or null.\<^footnote>\<open>See also the official specification
   266   \<^url>\<open>https://www.json.org\<close> and unofficial explorations ``Parsing JSON is a
   265   \<^url>\<open>https://www.json.org\<close> and unofficial explorations ``Parsing JSON is a
   267   Minefield'' \<^url>\<open>http://seriot.ch/parsing_json.php\<close>.\<close> Since JSON requires
   266   Minefield'' \<^url>\<open>http://seriot.ch/parsing_json.php\<close>.\<close> Since JSON requires
   268   explicit quotes and backslash-escapes to represent arbitrary text, the YXML
   267   explicit quotes and backslash-escapes to represent arbitrary text, the YXML
   269   notation for XML trees (\secref{sec:yxml-vs-xml}) works better
   268   notation for XML trees (\secref{sec:yxml-vs-xml}) works better
   270   for large messages with a lot of PIDE markup.
   269   for large messages with a lot of PIDE markup.
   818 
   817 
   819 subsubsection \<open>Results\<close>
   818 subsubsection \<open>Results\<close>
   820 
   819 
   821 text \<open>
   820 text \<open>
   822   The \<open>session_id\<close> provides the internal identification of the session object
   821   The \<open>session_id\<close> provides the internal identification of the session object
   823   within the sever process. It can remain active as long as the server is
   822   within the server process. It can remain active as long as the server is
   824   running, independently of the current client connection.
   823   running, independently of the current client connection.
   825 
   824 
   826   \<^medskip>
   825   \<^medskip>
   827   The \<open>tmp_dir\<close> field refers to a temporary directory that is specifically
   826   The \<open>tmp_dir\<close> field refers to a temporary directory that is specifically
   828   created for this session and deleted after it has been stopped. This may
   827   created for this session and deleted after it has been stopped. This may