src/Pure/General/long_name.scala
author wenzelm
Thu, 09 Feb 2017 22:40:15 +0100
changeset 65014 97a622d01609
parent 56800 b904ea8edd73
child 65358 e345e9420109
permissions -rw-r--r--
support for type Date;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56800
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/General/long_name.scala
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     3
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     4
Long names.
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     5
*/
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     6
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     7
package isabelle
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     8
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
     9
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    10
object Long_Name
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    11
{
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    12
  val separator = "."
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    13
  val separator_char = '.'
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    14
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    15
  def is_qualified(name: String): Boolean = name.contains(separator_char)
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    16
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    17
  def implode(names: List[String]): String = names.mkString(separator)
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    18
  def explode(name: String): List[String] = Library.space_explode(separator_char, name)
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    19
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    20
  def qualify(qual: String, name: String): String =
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    21
    if (qual == "" || name == "") name
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    22
    else qual + separator + name
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    23
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    24
  def base_name(name: String): String =
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    25
    if (name == "") ""
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    26
    else explode(name).last
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    27
}
b904ea8edd73 support for long names in Scala;
wenzelm
parents:
diff changeset
    28