author | wenzelm |
Sat, 04 Mar 2023 12:16:58 +0100 | |
changeset 77501 | 2d8815f98537 |
parent 77500 | bbb78dba6f68 |
child 80480 | 972f7a4cdc0e |
permissions | -rw-r--r-- |
57453 | 1 |
/* Title: Pure/General/output.scala |
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
3 |
|
77500 | 4 |
Console output channels. |
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
5 |
*/ |
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
6 |
|
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
8 |
|
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
9 |
|
75393 | 10 |
object Output { |
59671
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
11 |
def clean_yxml(msg: String): String = |
62938 | 12 |
try { XML.content(Protocol_Message.clean_reports(YXML.parse_body(msg))) } |
59671
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
13 |
catch { case ERROR(_) => msg } |
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
14 |
|
59671
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
15 |
def writeln_text(msg: String): String = clean_yxml(msg) |
65828 | 16 |
|
71647 | 17 |
def warning_prefix(s: String): String = Library.prefix_lines("### ", s) |
18 |
def warning_text(msg: String): String = warning_prefix(clean_yxml(msg)) |
|
65828 | 19 |
|
77501 | 20 |
def error_message_prefix(s: String): String = Library.prefix_lines("*** ", s) |
21 |
def error_message_text(msg: String): String = error_message_prefix(clean_yxml(msg)) |
|
59671
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
22 |
|
77500 | 23 |
def output(s: String, stdout: Boolean = false, include_empty: Boolean = false): Unit = |
24 |
if (s.nonEmpty || include_empty) { |
|
25 |
if (stdout) Console.print(s + "\n") else Console.err.print(s + "\n") |
|
62553 | 26 |
} |
27 |
||
77500 | 28 |
def writeln(msg: String, stdout: Boolean = false, include_empty: Boolean = false): Unit = |
29 |
output(writeln_text(msg), stdout = stdout, include_empty = include_empty) |
|
62553 | 30 |
|
77500 | 31 |
def warning(msg: String, stdout: Boolean = false, include_empty: Boolean = false): Unit = |
32 |
output(warning_text(msg), stdout = stdout, include_empty = include_empty) |
|
33 |
||
34 |
def error_message(msg: String, stdout: Boolean = false, include_empty: Boolean = false): Unit = |
|
35 |
output(error_message_text(msg), stdout = stdout, include_empty = include_empty) |
|
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
36 |
} |