equal
deleted
inserted
replaced
4 BibTeX support. |
4 BibTeX support. |
5 */ |
5 */ |
6 |
6 |
7 package isabelle |
7 package isabelle |
8 |
8 |
|
9 |
|
10 import java.io.{File => JFile} |
9 |
11 |
10 import scala.collection.mutable |
12 import scala.collection.mutable |
11 import scala.util.parsing.combinator.RegexParsers |
13 import scala.util.parsing.combinator.RegexParsers |
12 import scala.util.parsing.input.Reader |
14 import scala.util.parsing.input.Reader |
13 |
15 |
127 |
129 |
128 |
130 |
129 |
131 |
130 /** document model **/ |
132 /** document model **/ |
131 |
133 |
132 def check_name(name: String): Boolean = name.endsWith(".bib") |
134 /* bibtex files */ |
|
135 |
|
136 def is_bibtex(name: String): Boolean = name.endsWith(".bib") |
|
137 def is_bibtex_theory(name: Document.Node.Name): Boolean = is_bibtex(name.theory) |
|
138 |
|
139 private val node_suffix: String = "bibtex_file" |
|
140 |
|
141 def make_theory_name(resources: Resources, name: Document.Node.Name): Option[Document.Node.Name] = |
|
142 { |
|
143 Thy_Header.file_name(name.node) match { |
|
144 case Some(bib_name) if is_bibtex(bib_name) => |
|
145 val thy_node = resources.append(name.node, Path.explode(node_suffix)) |
|
146 Some(Document.Node.Name(thy_node, name.master_dir, bib_name)) |
|
147 case _ => None |
|
148 } |
|
149 } |
|
150 |
|
151 def make_theory_content(bib_name: String): Option[String] = |
|
152 if (is_bibtex(bib_name)) { |
|
153 Some("""theory "bib" imports Pure begin bibtex_file """ + quote(bib_name) + """ end""") |
|
154 } |
|
155 else None |
|
156 |
|
157 def make_theory_content(file: JFile): Option[String] = |
|
158 if (file.getName == node_suffix) { |
|
159 val parent = file.getParentFile |
|
160 if (parent != null && is_bibtex(parent.getName)) make_theory_content(parent.getName) |
|
161 else None |
|
162 } |
|
163 else None |
|
164 |
|
165 |
|
166 /* entries */ |
133 |
167 |
134 def entries(text: String): List[Text.Info[String]] = |
168 def entries(text: String): List[Text.Info[String]] = |
135 { |
169 { |
136 val result = new mutable.ListBuffer[Text.Info[String]] |
170 val result = new mutable.ListBuffer[Text.Info[String]] |
137 var offset = 0 |
171 var offset = 0 |