type Keywords = List[(String, Keyword.Spec)] type Abbrevs = List[(String, String)]
val CHAPTER = "chapter" val SECTION = "section" val SUBSECTION = "subsection" val SUBSUBSECTION = "subsubsection" val PARAGRAPH = "paragraph" val SUBPARAGRAPH = "subparagraph" val TEXT = "text" val TXT = "txt" val TEXT_RAW = "text_raw"
val THEORY = "theory" val IMPORTS = "imports" val KEYWORDS = "keywords" val ABBREVS = "abbrevs" val AND = "and" val BEGIN = "begin"
val bootstrap_keywords: Keyword.Keywords =
Keyword.Keywords.empty.add_keywords(bootstrap_header)
val bootstrap_syntax: Outer_Syntax =
Outer_Syntax.empty.add_keywords(bootstrap_header)
/* file name vs. theory name */
val PURE = "Pure" val ML_BOOTSTRAP = "ML_Bootstrap" val ml_roots = List("ROOT0.ML" -> "ML_Root0", "ROOT.ML" -> "ML_Root") val bootstrap_thys = List(PURE, ML_BOOTSTRAP).map(a => a -> ("Bootstrap_" + a))
val bootstrap_global_theories =
(Sessions.root_name :: (ml_roots ::: bootstrap_thys).map(_._2)).map(_ -> PURE)
def import_name(s: String): String =
Url.get_base_name(s) match { case Some(name) if !File.is_thy(name) => name case _ => error("Malformed theory import: " + quote(s))
}
def theory_name(s: String): String =
get_thy_name(s) match { case Some(name) =>
bootstrap_thys.collectFirst({ case (a, b) if a == name => b }).getOrElse(name) case None =>
Url.get_base_name(s) match { case Some(name) => if (name == Sessions.root_name) name else ml_roots.collectFirst({ case (a, b) if a == name => b }).getOrElse("") case None => ""
}
}
def is_ml_root(theory: String): Boolean =
ml_roots.exists({ case (_, b) => b == theory })
def is_bootstrap(theory: String): Boolean =
bootstrap_thys.exists({ case (_, b) => b == theory })
/* parser */
trait Parsers extends Parse.Parsers { val header: Parser[Thy_Header] = { val load_command =
($$$("(") ~! (position(name) <~ $$$(")")) ^^ { case _ ~ x => x }) |
success(("", Position.none))
val keyword_kind = atom("outer syntax keyword specification", _.is_name) val keyword_spec =
position(keyword_kind) ~ load_command ~ tags ^^
{ case (a, b) ~ c ~ d =>
Keyword.Spec(kind = a, kind_pos = b,
load_command = c._1, load_command_pos = c._2, tags = d)
}
val keyword_decl =
rep1(string) ~
opt($$$("::") ~! keyword_spec ^^ { case _ ~ x => x }) ^^
{ case xs ~ y => xs.map((_, y.getOrElse(Keyword.Spec()))) }
val keyword_decls =
keyword_decl ~ rep($$$(AND) ~! keyword_decl ^^ { case _ ~ x => x }) ^^
{ case xs ~ yss => (xs :: yss).flatten }
val abbrevs =
rep1sep(rep1(text) ~ ($$$("=") ~! rep1(text)), $$$("and")) ^^
{ case res => for ((as ~ (_ ~ bs)) <- res; a <- as; b <- bs) yield (a, b) }
val args =
position(this.theory_name) ~
(opt($$$(IMPORTS) ~! rep1(position(this.theory_name))) ^^
{ case None => Nil case Some(_ ~ xs) => xs }) ~
(opt($$$(KEYWORDS) ~! keyword_decls) ^^
{ case None => Nil case Some(_ ~ xs) => xs }) ~
(opt($$$(ABBREVS) ~! abbrevs) ^^
{ case None => Nil case Some(_ ~ xs) => xs }) ~
$$$(BEGIN) ^^ { case a ~ b ~ c ~ d ~ _ => Thy_Header(a._1, a._2, b, c, d) }
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.