src/Pure/Isar/outer_syntax.scala
changeset 73115 a8e5d7c9a834
parent 72800 85bcdd05c6d0
child 73120 c3589f2dff31
equal deleted inserted replaced
73114:9bf36baa8686 73115:a8e5d7c9a834
   163   def parse_spans(toks: List[Token]): List[Command_Span.Span] =
   163   def parse_spans(toks: List[Token]): List[Command_Span.Span] =
   164   {
   164   {
   165     val result = new mutable.ListBuffer[Command_Span.Span]
   165     val result = new mutable.ListBuffer[Command_Span.Span]
   166     val content = new mutable.ListBuffer[Token]
   166     val content = new mutable.ListBuffer[Token]
   167     val ignored = new mutable.ListBuffer[Token]
   167     val ignored = new mutable.ListBuffer[Token]
   168     var start = 0
       
   169 
   168 
   170     def ship(content: List[Token])
   169     def ship(content: List[Token])
   171     {
   170     {
   172       val kind =
   171       val kind =
   173         if (content.forall(_.is_ignored)) Command_Span.Ignored_Span
   172         if (content.forall(_.is_ignored)) Command_Span.Ignored_Span
   180               val offset =
   179               val offset =
   181                 (0 /: content.takeWhile(_ != cmd)) {
   180                 (0 /: content.takeWhile(_ != cmd)) {
   182                   case (i, tok) => i + Symbol.length(tok.source) }
   181                   case (i, tok) => i + Symbol.length(tok.source) }
   183               val end_offset = offset + Symbol.length(name)
   182               val end_offset = offset + Symbol.length(name)
   184               val range = Text.Range(offset, end_offset) + 1
   183               val range = Text.Range(offset, end_offset) + 1
   185               val pos = Position.Range(range)
   184               Command_Span.Command_Span(name, Position.Range(range))
   186               val abs_pos = Position.Range(range + start)
       
   187               Command_Span.Command_Span(name, pos, abs_pos)
       
   188           }
   185           }
   189       for (tok <- content) start += Symbol.length(tok.source)
       
   190       result += Command_Span.Span(kind, content)
   186       result += Command_Span.Span(kind, content)
   191     }
   187     }
   192 
   188 
   193     def flush()
   189     def flush()
   194     {
   190     {