author | wenzelm |
Tue, 02 Jun 2009 21:36:22 +0200 | |
changeset 34584 | 3457ef52de04 |
parent 34554 | 7dc6c231da40 |
child 34585 | 4c65620f5318 |
permissions | -rw-r--r-- |
34407 | 1 |
/* |
2 |
* Document tokens as text ranges |
|
3 |
* |
|
4 |
* @author Johannes Hölzl, TU Munich |
|
5 |
* @author Fabian Immler, TU Munich |
|
6 |
*/ |
|
7 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
8 |
package isabelle.proofdocument |
34483 | 9 |
|
10 |
||
34481
660c639870a4
replaced type parameter C by Command (thanks to globally simultaneous scope);
wenzelm
parents:
34407
diff
changeset
|
11 |
import isabelle.prover.Command |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
12 |
|
34483 | 13 |
|
34388 | 14 |
object Token { |
34482 | 15 |
object Kind extends Enumeration { |
16 |
val COMMAND_START = Value("COMMAND_START") |
|
17 |
val COMMENT = Value("COMMENT") |
|
18 |
val OTHER = Value("OTHER") |
|
34388 | 19 |
} |
34389 | 20 |
|
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34539
diff
changeset
|
21 |
def string_from_tokens (tokens: List[Token], starts: Map[Token, Int]): String = { |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34539
diff
changeset
|
22 |
def stop(t: Token) = starts(t) + t.length |
34526 | 23 |
tokens match { |
24 |
case Nil => "" |
|
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34539
diff
changeset
|
25 |
case t::tokens => ( tokens.foldLeft |
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34539
diff
changeset
|
26 |
(t.content, stop(t)) |
34584 | 27 |
((a, token) => (a._1 + " " * (starts(token) - a._2) + token.content, stop(token))) |
34526 | 28 |
)._1 |
34389 | 29 |
} |
30 |
} |
|
34526 | 31 |
|
34388 | 32 |
} |
33 |
||
34551
bd2b8fde9e25
incomplete changes of immutable tokens and commands
immler@in.tum.de
parents:
34539
diff
changeset
|
34 |
class Token(val content: String, val kind: Token.Kind.Value) { |
34526 | 35 |
val length = content.length |
34554
7dc6c231da40
abs. stops, markup nodes depend on doc-version;
immler@in.tum.de
parents:
34551
diff
changeset
|
36 |
override def toString = content |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
37 |
} |