equal
deleted
inserted
replaced
9 package isabelle |
9 package isabelle |
10 |
10 |
11 |
11 |
12 import scala.collection.immutable.SortedMap |
12 import scala.collection.immutable.SortedMap |
13 import scala.util.parsing.combinator.RegexParsers |
13 import scala.util.parsing.combinator.RegexParsers |
|
14 import scala.util.matching.Regex |
14 import scala.math.Ordering |
15 import scala.math.Ordering |
15 |
16 |
16 |
17 |
17 object Completion |
18 object Completion |
18 { |
19 { |
217 |
218 |
218 private object Word_Parsers extends RegexParsers |
219 private object Word_Parsers extends RegexParsers |
219 { |
220 { |
220 override val whiteSpace = "".r |
221 override val whiteSpace = "".r |
221 |
222 |
|
223 private val symbol_regex: Regex = """\\<\^?[A-Za-z0-9_']+>""".r |
|
224 def is_symbol(s: CharSequence): Boolean = symbol_regex.pattern.matcher(s).matches |
|
225 |
222 private def reverse_symbol: Parser[String] = """>[A-Za-z0-9_']+\^?<\\""".r |
226 private def reverse_symbol: Parser[String] = """>[A-Za-z0-9_']+\^?<\\""".r |
223 private def reverse_symb: Parser[String] = """[A-Za-z0-9_']{2,}\^?<\\""".r |
227 private def reverse_symb: Parser[String] = """[A-Za-z0-9_']{2,}\^?<\\""".r |
224 private def escape: Parser[String] = """[a-zA-Z0-9_']+\\""".r |
228 private def escape: Parser[String] = """[a-zA-Z0-9_']+\\""".r |
225 |
229 |
226 private val word_regex = "[a-zA-Z0-9_'.]+".r |
230 private val word_regex = "[a-zA-Z0-9_'.]+".r |
345 abbrevs match { |
349 abbrevs match { |
346 case Nil => None |
350 case Nil => None |
347 case (a, _) :: _ => |
351 case (a, _) :: _ => |
348 val ok = |
352 val ok = |
349 if (a == Completion.antiquote) language_context.antiquotes |
353 if (a == Completion.antiquote) language_context.antiquotes |
350 else language_context.symbols || Completion.default_abbrs.exists(_._1 == a) |
354 else |
|
355 language_context.symbols || |
|
356 Completion.default_abbrs.exists(_._1 == a) || |
|
357 Completion.Word_Parsers.is_symbol(a) |
351 if (ok) Some((a, abbrevs)) |
358 if (ok) Some((a, abbrevs)) |
352 else None |
359 else None |
353 } |
360 } |
354 case _ => None |
361 case _ => None |
355 } |
362 } |