src/Pure/library.scala
author wenzelm
Thu, 21 Nov 2013 17:45:37 +0100
changeset 54548 41e4ba92a979
parent 52444 2cfe6656d6d6
child 55033 8e8243975860
permissions -rw-r--r--
proper concatenation of messages;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34136
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/library.scala
45673
cd41e3903fbf separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
wenzelm
parents: 45667
diff changeset
     2
    Module:     PIDE
34136
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     3
    Author:     Makarius
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     4
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     5
Basic library.
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     6
*/
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     7
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     8
package isabelle
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
     9
38258
dd7dcb9b2637 added Library.thread_actor -- thread as actor;
wenzelm
parents: 38232
diff changeset
    10
51981
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    11
import scala.collection.mutable
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    12
49245
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents: 48996
diff changeset
    13
import java.util.Locale
50414
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
    14
import java.util.concurrent.{Future => JFuture, TimeUnit}
37018
39f4cce5a22c added somewhat generic zoom box;
wenzelm
parents: 36791
diff changeset
    15
39f4cce5a22c added somewhat generic zoom box;
wenzelm
parents: 36791
diff changeset
    16
34136
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
    17
object Library
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
    18
{
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    19
  /* user errors */
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    20
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    21
  object ERROR
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    22
  {
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    23
    def apply(message: String): Throwable = new RuntimeException(message)
48479
819f7a5f3e7f more general notion of user ERROR (cf. 44f56fe01528);
wenzelm
parents: 48425
diff changeset
    24
    def unapply(exn: Throwable): Option[String] = Exn.user_message(exn)
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    25
  }
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    26
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    27
  def error(message: String): Nothing = throw ERROR(message)
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    28
54548
41e4ba92a979 proper concatenation of messages;
wenzelm
parents: 52444
diff changeset
    29
  def cat_message(msg1: String, msg2: String): String =
41e4ba92a979 proper concatenation of messages;
wenzelm
parents: 52444
diff changeset
    30
    if (msg1 == "") msg2
41e4ba92a979 proper concatenation of messages;
wenzelm
parents: 52444
diff changeset
    31
    else msg1 + "\n" + msg2
41e4ba92a979 proper concatenation of messages;
wenzelm
parents: 52444
diff changeset
    32
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    33
  def cat_error(msg1: String, msg2: String): Nothing =
54548
41e4ba92a979 proper concatenation of messages;
wenzelm
parents: 52444
diff changeset
    34
    error(cat_message(msg1, msg2))
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    35
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
    36
48996
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    37
  /* separated chunks */
36688
321d392ab12e added separate;
wenzelm
parents: 36685
diff changeset
    38
321d392ab12e added separate;
wenzelm
parents: 36685
diff changeset
    39
  def separate[A](s: A, list: List[A]): List[A] =
51981
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    40
  {
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    41
    val result = new mutable.ListBuffer[A]
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    42
    var first = true
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    43
    for (x <- list) {
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    44
      if (first) {
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    45
        first = false
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    46
        result += x
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    47
      }
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    48
      else {
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    49
        result += s
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    50
        result += x
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    51
      }
36688
321d392ab12e added separate;
wenzelm
parents: 36685
diff changeset
    52
    }
51981
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    53
    result.toList
a8ffd3692f57 more scalable Library.separate -- NB: JVM has tiny fixed-size stack;
wenzelm
parents: 51616
diff changeset
    54
  }
36688
321d392ab12e added separate;
wenzelm
parents: 36685
diff changeset
    55
48996
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    56
  def separated_chunks(sep: Char, source: CharSequence): Iterator[CharSequence] =
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    57
    new Iterator[CharSequence] {
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    58
      private val end = source.length
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    59
      private def next_chunk(i: Int): Option[(CharSequence, Int)] =
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    60
      {
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    61
        if (i < end) {
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    62
          var j = i; do j += 1 while (j < end && source.charAt(j) != sep)
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    63
          Some((source.subSequence(i + 1, j), j))
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    64
        }
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    65
        else None
43598
826ddd91ae2b basic operations on lists and strings;
wenzelm
parents: 43442
diff changeset
    66
      }
48996
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    67
      private var state: Option[(CharSequence, Int)] = if (end == 0) None else next_chunk(-1)
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    68
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    69
      def hasNext(): Boolean = state.isDefined
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    70
      def next(): CharSequence =
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    71
        state match {
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    72
          case Some((s, i)) => { state = next_chunk(i); s }
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    73
          case None => Iterator.empty.next()
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    74
        }
43598
826ddd91ae2b basic operations on lists and strings;
wenzelm
parents: 43442
diff changeset
    75
    }
826ddd91ae2b basic operations on lists and strings;
wenzelm
parents: 43442
diff changeset
    76
48996
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    77
  def space_explode(sep: Char, str: String): List[String] =
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    78
    separated_chunks(sep, str).map(_.toString).toList
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    79
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    80
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    81
  /* lines */
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    82
51983
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
    83
  def terminate_lines(lines: Iterable[CharSequence]): Iterable[CharSequence] =
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
    84
    new Iterable[CharSequence] {
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
    85
      def iterator: Iterator[CharSequence] =
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
    86
        lines.iterator.map(line => new Line_Termination(line))
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
    87
    }
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
    88
48996
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    89
  def cat_lines(lines: TraversableOnce[String]): String = lines.mkString("\n")
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    90
43670
7f933761764b prefer space_explode/split_lines as in Isabelle/ML;
wenzelm
parents: 43652
diff changeset
    91
  def split_lines(str: String): List[String] = space_explode('\n', str)
7f933761764b prefer space_explode/split_lines as in Isabelle/ML;
wenzelm
parents: 43652
diff changeset
    92
48996
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    93
  def first_line(source: CharSequence): String =
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    94
  {
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    95
    val lines = separated_chunks('\n', source)
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    96
    if (lines.hasNext) lines.next.toString
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    97
    else ""
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    98
  }
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
    99
50847
78c40f1cc9b3 tuned signature;
wenzelm
parents: 50845
diff changeset
   100
78c40f1cc9b3 tuned signature;
wenzelm
parents: 50845
diff changeset
   101
  /* strings */
78c40f1cc9b3 tuned signature;
wenzelm
parents: 50845
diff changeset
   102
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 49470
diff changeset
   103
  def lowercase(str: String): String = str.toLowerCase(Locale.ENGLISH)
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 49470
diff changeset
   104
  def uppercase(str: String): String = str.toUpperCase(Locale.ENGLISH)
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 49470
diff changeset
   105
49245
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents: 48996
diff changeset
   106
  def capitalize(str: String): String =
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents: 48996
diff changeset
   107
    if (str.length == 0) str
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 49470
diff changeset
   108
    else uppercase(str.substring(0, 1)) + str.substring(1)
49245
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents: 48996
diff changeset
   109
50847
78c40f1cc9b3 tuned signature;
wenzelm
parents: 50845
diff changeset
   110
  def try_unprefix(prfx: String, s: String): Option[String] =
78c40f1cc9b3 tuned signature;
wenzelm
parents: 50845
diff changeset
   111
    if (s.startsWith(prfx)) Some(s.substring(prfx.length)) else None
78c40f1cc9b3 tuned signature;
wenzelm
parents: 50845
diff changeset
   112
52444
2cfe6656d6d6 slightly improved "isabelle doc" based on Isabelle/Scala;
wenzelm
parents: 51983
diff changeset
   113
  def trim_line(s: String): String =
2cfe6656d6d6 slightly improved "isabelle doc" based on Isabelle/Scala;
wenzelm
parents: 51983
diff changeset
   114
    if (s.endsWith("\r\n")) s.substring(0, s.length - 2)
2cfe6656d6d6 slightly improved "isabelle doc" based on Isabelle/Scala;
wenzelm
parents: 51983
diff changeset
   115
    else if (s.endsWith("\r") || s.endsWith("\n")) s.substring(0, s.length - 1)
2cfe6656d6d6 slightly improved "isabelle doc" based on Isabelle/Scala;
wenzelm
parents: 51983
diff changeset
   116
    else s
2cfe6656d6d6 slightly improved "isabelle doc" based on Isabelle/Scala;
wenzelm
parents: 51983
diff changeset
   117
43598
826ddd91ae2b basic operations on lists and strings;
wenzelm
parents: 43442
diff changeset
   118
48996
a8bad1369ada clarified separated_chunks vs. space_explode;
wenzelm
parents: 48479
diff changeset
   119
  /* quote */
46196
805de058722b added cat_lines convenience;
wenzelm
parents: 45900
diff changeset
   120
43598
826ddd91ae2b basic operations on lists and strings;
wenzelm
parents: 43442
diff changeset
   121
  def quote(s: String): String = "\"" + s + "\""
826ddd91ae2b basic operations on lists and strings;
wenzelm
parents: 43442
diff changeset
   122
  def commas(ss: Iterable[String]): String = ss.iterator.mkString(", ")
48362
c3192ccb0ff4 proper commas_quote;
wenzelm
parents: 48345
diff changeset
   123
  def commas_quote(ss: Iterable[String]): String = ss.iterator.map(quote).mkString(", ")
43598
826ddd91ae2b basic operations on lists and strings;
wenzelm
parents: 43442
diff changeset
   124
36688
321d392ab12e added separate;
wenzelm
parents: 36685
diff changeset
   125
51983
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   126
  /* CharSequence */
34141
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   127
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   128
  class Reverse(text: CharSequence, start: Int, end: Int) extends CharSequence
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   129
  {
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   130
    require(0 <= start && start <= end && end <= text.length)
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   131
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   132
    def this(text: CharSequence) = this(text, 0, text.length)
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   133
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   134
    def length: Int = end - start
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   135
    def charAt(i: Int): Char = text.charAt(end - i - 1)
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   136
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   137
    def subSequence(i: Int, j: Int): CharSequence =
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   138
      if (0 <= i && i <= j && j <= length) new Reverse(text, end - j, end - i)
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   139
      else throw new IndexOutOfBoundsException
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   140
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   141
    override def toString: String =
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   142
    {
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   143
      val buf = new StringBuilder(length)
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   144
      for (i <- 0 until length)
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   145
        buf.append(charAt(i))
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   146
      buf.toString
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   147
    }
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   148
  }
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   149
51983
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   150
  class Line_Termination(text: CharSequence) extends CharSequence
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   151
  {
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   152
    def length: Int = text.length + 1
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   153
    def charAt(i: Int): Char = if (i == text.length) '\n' else text.charAt(i)
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   154
    def subSequence(i: Int, j: Int): CharSequence =
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   155
      if (j == text.length + 1) new Line_Termination(text.subSequence(i, j - 1))
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   156
      else text.subSequence(i, j)
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   157
    override def toString: String = text.toString + "\n"
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   158
  }
32692ce4c61a more frugal line termination, to cope with huge log files (see also 016cb7d8f297);
wenzelm
parents: 51981
diff changeset
   159
34141
297b2149077d simiplified result of keyword parser (again);
wenzelm
parents: 34136
diff changeset
   160
50414
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   161
  /* Java futures */
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   162
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   163
  def future_value[A](x: A) = new JFuture[A]
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   164
  {
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   165
    def cancel(may_interrupt: Boolean): Boolean = false
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   166
    def isCancelled(): Boolean = false
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   167
    def isDone(): Boolean = true
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   168
    def get(): A = x
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   169
    def get(timeout: Long, time_unit: TimeUnit): A = x
e17a1f179bb0 explore theory_body_files via future, for improved performance;
wenzelm
parents: 50299
diff changeset
   170
  }
34136
3dcb46ae6185 added basic library -- Scala version;
wenzelm
parents:
diff changeset
   171
}
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   172
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   173
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   174
class Basic_Library
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   175
{
43670
7f933761764b prefer space_explode/split_lines as in Isabelle/ML;
wenzelm
parents: 43652
diff changeset
   176
  val ERROR = Library.ERROR
7f933761764b prefer space_explode/split_lines as in Isabelle/ML;
wenzelm
parents: 43652
diff changeset
   177
  val error = Library.error _
7f933761764b prefer space_explode/split_lines as in Isabelle/ML;
wenzelm
parents: 43652
diff changeset
   178
  val cat_error = Library.cat_error _
7f933761764b prefer space_explode/split_lines as in Isabelle/ML;
wenzelm
parents: 43652
diff changeset
   179
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   180
  val space_explode = Library.space_explode _
43670
7f933761764b prefer space_explode/split_lines as in Isabelle/ML;
wenzelm
parents: 43652
diff changeset
   181
  val split_lines = Library.split_lines _
46196
805de058722b added cat_lines convenience;
wenzelm
parents: 45900
diff changeset
   182
  val cat_lines = Library.cat_lines _
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   183
  val quote = Library.quote _
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   184
  val commas = Library.commas _
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   185
  val commas_quote = Library.commas_quote _
49470
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   186
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   187
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   188
  /* parallel tasks */
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   189
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   190
  implicit def function_as_callable[A](f: () => A) =
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   191
    new java.util.concurrent.Callable[A] { def call = f() }
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   192
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   193
  val default_thread_pool =
ee564db2649b more management of Invoke_Scala tasks;
wenzelm
parents: 49245
diff changeset
   194
    scala.collection.parallel.ThreadPoolTasks.defaultThreadPool
43652
dcd0b667f73d pervasive Basic_Library in Scala;
wenzelm
parents: 43598
diff changeset
   195
}