def parse(content: String): List[Spec] = { val parser = Parsers.repsep(Parsers.option_spec, Parsers.$$$(",")) val reader = Token.reader(Token.explode(syntax.keywords, content), Token.Pos.none)
Parsers.parse_all(parser, reader) match { case Parsers.Success(result, _) => result case bad => error(bad.toString)
}
}
def print_value(s: String): String =
s match { case Value.Boolean(_) => s case Value.Long(_) => s case Value.Double(_) => s case _ => Token.quote_name(syntax.keywords, s)
}
val TAG_CONTENT = "content" // formal theory content val TAG_DOCUMENT = "document" // document preparation val TAG_BUILD = "build" // relevant for"isabelle build" val TAG_BUILD_SYNC = "build_sync" // relevant for distributed "isabelle build" val TAG_UPDATE = "update" // relevant for"isabelle update" val TAG_CONNECTION = "connection" // private information about connections (password etc.) val TAG_COLOR_DIALOG = "color_dialog" // special color selection dialog val TAG_VSCODE = "vscode" // relevant for"isabelle vscode" and "isabelle vscode_server"
val SUFFIX_DARK = "_dark" def theme_suffix(): String = if (GUI.is_dark_laf()) SUFFIX_DARK else""
caseclass Entry(
public: Boolean,
pos: Position.T,
name: String,
typ: Type,
value: String,
default_value: String,
standard_value: Option[String],
tags: List[String],
description: String,
section: String
) { privatedef print_value(x: String): String = if (typ == Options.String) quote(x) else x privatedef print_standard: String =
standard_value match { case None => "" case Some(s) if s == default_value => " (standard)" case Some(s) => " (standard " + print_value(s) + ")"
} privatedef print(default: Boolean): String = { val x = if (default) default_value else value "option " + name + " : " + typ.print + " = " + print_value(x) + print_standard +
if_proper(description, "\n -- " + quote(description))
}
def title(strip: String = ""): String = { val words = Word.explode('_', name) val words1 =
words match { case word :: rest if word == strip => rest case _ => words
}
Word.implode(words1.map(Word.perhaps_capitalized))
} def title_jedit: String = title("jedit")
val prefs_syntax: Outer_Syntax = Outer_Syntax.empty + "="
trait Parsers extends Parse.Parsers { val option_name: Parser[String] = atom("option name", _.is_name) val option_type: Parser[String] = atom("option type", _.is_name) val option_value: Parser[String] =
opt(token("-", tok => tok.is_sym_ident && tok.content == "-")) ~ atom("nat", _.is_nat) ^^
{ case s ~ n => if (s.isDefined) "-" + n else n } |
atom("option value", tok => tok.is_name || tok.is_float) val option_standard: Parser[Option[String]] =
$$$("(") ~! $$$(STANDARD) ~ opt(option_value) ~ $$$(")") ^^ { case _ ~ _ ~ a ~ _ => a } val option_tag: Parser[String] = atom("option tag", _.is_name) val option_tags: Parser[List[String]] =
$$$(FOR) ~! rep(option_tag) ^^ { case _ ~ x => x } | success(Nil) val option_spec: Parser[Spec] =
option_name ~ opt($$$("=") ~! option_value ^^ { case _ ~ x => x }) ^^
{ case x ~ y => Options.Spec(x, value = y) }
}
def init(prefs: String = read_prefs(file = PREFS), specs: List[Spec] = Nil): Options = { var options = empty for {
dir <- Components.directories()
file = dir + OPTIONS if file.is_file
} { options = Parsers.parse_file(options, file.implode, File.read(file)) }
Parsers.parse_prefs(options, prefs) ++ specs
}
def init0(): Options = init(prefs = "")
/* Isabelle tool wrapper */
val isabelle_tool = Isabelle_Tool("options", "print Isabelle system options",
Scala_Project.here,
{ args => var build_options = false var get_option = "" var list_options = false var list_tags = List.empty[String] var export_file = ""
val getopts = Getopts("""
Usage: isabelle options [OPTIONS] [MORE_OPTIONS ...]
Options are:
-b include $ISABELLE_BUILD_OPTIONS
-g OPTION get value of OPTION
-l list options
-t TAGS restrict list to given tags (comma-separated)
-x FILE export options to FILE in YXML format
Report Isabelle system options, augmented by MORE_OPTIONS given as
arguments NAME=VAL or NAME. """, "b" -> (_ => build_options = true), "g:" -> (arg => get_option = arg), "l" -> (_ => list_options = true), "t:" -> (arg => list_tags = space_explode(',', arg)), "x:" -> (arg => export_file = arg))
val more_options = getopts(args) if (get_option == "" && !list_options && export_file == "") getopts.usage()
val options = { val options0 = Options.init() val options1 = if (build_options) options0 ++ Options.Spec.ISABELLE_BUILD_OPTIONS else options0
more_options.foldLeft(options1)(_ + _)
}
if (get_option != "") {
Output.writeln(options.check_name(get_option).value, stdout = true)
}
if (export_file != "") {
File.write(Path.explode(export_file), YXML.string_of_body(options.encode))
}
privatedef check_value(name: String): Options = { val opt = check_name(name)
opt.typ match { case Options.Bool => bool(name); this case Options.Int => int(name); this case Options.Real => real(name); this case Options.String => string(name); this case Options.Unknown => this
}
}
def declare(
public: Boolean,
pos: Position.T,
name: String,
typ_name: String,
value: String,
standard: Option[Option[String]],
tags: List[String],
description: String
): Options = {
get(name) match { case Some(other) =>
error("Duplicate declaration of option " + quote(name) + Position.here(pos) +
Position.here(other.pos)) case None => val typ =
typ_name match { case"bool" => Options.Bool case"int" => Options.Int case"real" => Options.Real case"string" => Options.String case _ =>
error("Unknown type for option " + quote(name) + " : " + quote(typ_name) +
Position.here(pos))
} val standard_value =
standard match { case None => None case Some(_) if typ == Options.Bool =>
error("Illegal standard value for option " + quote(name) + " : " + typ_name +
Position.here) case Some(s) => Some(s.getOrElse(value))
} val opt =
Options.Entry(
public, pos, name, typ, value, value, standard_value, tags, description, section)
(new Options(options + (name -> opt), section)).check_value(name)
}
}
def + (spec: Options.Spec): Options = { val name = spec.name if (spec.permissive && !defined(name)) { val value = spec.value.getOrElse("") val opt =
Options.Entry(false, Position.none, name, Options.Unknown, value, value, None, Nil, "", "") new Options(options + (name -> opt), section)
} else { val opt = check_name(name) def put(value: String): Options =
(new Options(options + (name -> opt.copy(value = value)), section)).check_value(name)
spec.value orElse opt.standard_value match { case Some(value) => put(value) case None if opt.typ == Options.Bool => put("true") case None => error("Missing value for option " + quote(name) + " : " + opt.typ.print)
}
}
}
def + (s: String): Options = this + Options.Spec.make(s)
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 und die Messung sind noch experimentell.