1 /* Title: Pure/Isar/outer_syntax.scala
4 Isabelle/Isar outer syntax.
10 import scala.util.parsing.input.{Reader, CharSequenceReader}
13 class Outer_Syntax(symbols: Symbol.Interpretation)
15 protected val keywords: Map[String, String] = Map((";" -> Outer_Keyword.DIAG))
16 protected val lexicon: Scan.Lexicon = Scan.Lexicon.empty
17 lazy val completion: Completion = new Completion + symbols // FIXME !?
19 def + (name: String, kind: String): Outer_Syntax =
21 val new_keywords = keywords + (name -> kind)
22 val new_lexicon = lexicon + name
23 val new_completion = completion + name
24 new Outer_Syntax(symbols) {
25 override val lexicon = new_lexicon
26 override val keywords = new_keywords
27 override lazy val completion = new_completion
31 def + (name: String): Outer_Syntax = this + (name, Outer_Keyword.MINOR)
33 def is_command(name: String): Boolean =
34 keywords.get(name) match {
35 case Some(kind) => kind != Outer_Keyword.MINOR
42 def scan(input: Reader[Char]): List[Outer_Lex.Token] =
46 parseAll(rep(token(symbols, is_command)), input) match {
47 case Success(tokens, _) => tokens
48 case _ => error("Unexpected failure of tokenizing input:\n" + input.source.toString)
52 def scan(input: CharSequence): List[Outer_Lex.Token] =
53 scan(new CharSequenceReader(input))