author | wenzelm |
Mon, 11 Jul 2016 16:36:29 +0200 | |
changeset 63441 | 4c3fa4dba79f |
parent 63429 | baedd4724f08 |
child 63458 | 723f9c673c1c |
permissions | -rw-r--r-- |
34166 | 1 |
/* Title: Pure/Isar/outer_syntax.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Isabelle/Isar outer syntax. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
43411
0206466ee473
some support for partial scans with explicit context;
wenzelm
parents:
40533
diff
changeset
|
10 |
import scala.collection.mutable |
58706 | 11 |
import scala.annotation.tailrec |
34166 | 12 |
|
13 |
||
43774
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
14 |
object Outer_Syntax |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
15 |
{ |
58706 | 16 |
/* syntax */ |
17 |
||
18 |
val empty: Outer_Syntax = new Outer_Syntax() |
|
19 |
||
20 |
def init(): Outer_Syntax = new Outer_Syntax(completion = Completion.init()) |
|
21 |
||
22 |
||
23 |
/* string literals */ |
|
24 |
||
43774
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
25 |
def quote_string(str: String): String = |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
26 |
{ |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
27 |
val result = new StringBuilder(str.length + 10) |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
28 |
result += '"' |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
29 |
for (s <- Symbol.iterator(str)) { |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
30 |
if (s.length == 1) { |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
31 |
val c = s(0) |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
32 |
if (c < 32 && c != YXML.X && c != YXML.Y || c == '\\' || c == '"') { |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
33 |
result += '\\' |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
34 |
if (c < 10) result += '0' |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
35 |
if (c < 100) result += '0' |
60215 | 36 |
result ++= c.asInstanceOf[Int].toString |
43774
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
37 |
} |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
38 |
else result += c |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
39 |
} |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
40 |
else result ++= s |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
41 |
} |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
42 |
result += '"' |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
43 |
result.toString |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
44 |
} |
46626 | 45 |
|
58696 | 46 |
|
58697 | 47 |
/* line-oriented structure */ |
58696 | 48 |
|
58697 | 49 |
object Line_Structure |
58696 | 50 |
{ |
58700 | 51 |
val init = Line_Structure() |
58696 | 52 |
} |
53 |
||
58700 | 54 |
sealed case class Line_Structure( |
55 |
improper: Boolean = true, |
|
56 |
command: Boolean = false, |
|
57 |
depth: Int = 0, |
|
58 |
span_depth: Int = 0, |
|
59 |
after_span_depth: Int = 0) |
|
58706 | 60 |
|
61 |
||
62 |
/* overall document structure */ |
|
63 |
||
64 |
sealed abstract class Document { def length: Int } |
|
58747 | 65 |
case class Document_Block(name: String, text: String, body: List[Document]) extends Document |
58706 | 66 |
{ |
67 |
val length: Int = (0 /: body)(_ + _.length) |
|
68 |
} |
|
58747 | 69 |
case class Document_Atom(command: Command) extends Document |
58706 | 70 |
{ |
71 |
def length: Int = command.length |
|
72 |
} |
|
43774
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
73 |
} |
6dfdb70496fe
added Outer_Syntax.quote_string, which is conceptually a bit different from Token.unparse;
wenzelm
parents:
43695
diff
changeset
|
74 |
|
46712 | 75 |
final class Outer_Syntax private( |
58900 | 76 |
val keywords: Keyword.Keywords = Keyword.Keywords.empty, |
53280
c63a016805b9
explicit indication of outer syntax with no tokens;
wenzelm
parents:
52439
diff
changeset
|
77 |
val completion: Completion = Completion.empty, |
55749 | 78 |
val language_context: Completion.Language_Context = Completion.Language_Context.outer, |
56393
22f533e6a049
more abstract Prover.Syntax, as proposed by Carst Tankink;
wenzelm
parents:
56314
diff
changeset
|
79 |
val has_tokens: Boolean = true) extends Prover.Syntax |
34166 | 80 |
{ |
58706 | 81 |
/** syntax content **/ |
82 |
||
58900 | 83 |
override def toString: String = keywords.toString |
56393
22f533e6a049
more abstract Prover.Syntax, as proposed by Carst Tankink;
wenzelm
parents:
56314
diff
changeset
|
84 |
|
58695 | 85 |
|
86 |
/* add keywords */ |
|
87 |
||
63429 | 88 |
def + (name: String, kind: String = "", tags: List[String] = Nil, replace: Option[String] = None) |
58901 | 89 |
: Outer_Syntax = |
53280
c63a016805b9
explicit indication of outer syntax with no tokens;
wenzelm
parents:
52439
diff
changeset
|
90 |
{ |
63429 | 91 |
val keywords1 = keywords + (name, kind, tags) |
53280
c63a016805b9
explicit indication of outer syntax with no tokens;
wenzelm
parents:
52439
diff
changeset
|
92 |
val completion1 = |
58853 | 93 |
if (replace == Some("")) completion |
53280
c63a016805b9
explicit indication of outer syntax with no tokens;
wenzelm
parents:
52439
diff
changeset
|
94 |
else completion + (name, replace getOrElse name) |
58900 | 95 |
new Outer_Syntax(keywords1, completion1, language_context, true) |
53280
c63a016805b9
explicit indication of outer syntax with no tokens;
wenzelm
parents:
52439
diff
changeset
|
96 |
} |
48706 | 97 |
|
48873 | 98 |
def add_keywords(keywords: Thy_Header.Keywords): Outer_Syntax = |
99 |
(this /: keywords) { |
|
63429 | 100 |
case (syntax, (name, ((kind, tags), _), replace)) => |
50128
599c935aac82
alternative completion for outer syntax keywords;
wenzelm
parents:
48885
diff
changeset
|
101 |
syntax + |
63429 | 102 |
(Symbol.decode(name), kind, tags, replace) + |
103 |
(Symbol.encode(name), kind, tags, replace) |
|
46940 | 104 |
} |
34166 | 105 |
|
58695 | 106 |
|
59073 | 107 |
/* merge */ |
108 |
||
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59073
diff
changeset
|
109 |
def ++ (other: Prover.Syntax): Prover.Syntax = |
59073 | 110 |
if (this eq other) this |
111 |
else { |
|
59077
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59073
diff
changeset
|
112 |
val keywords1 = keywords ++ other.asInstanceOf[Outer_Syntax].keywords |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59073
diff
changeset
|
113 |
val completion1 = completion ++ other.asInstanceOf[Outer_Syntax].completion |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59073
diff
changeset
|
114 |
if ((keywords eq keywords1) && (completion eq completion1)) this |
7e0d3da6e6d8
node-specific syntax, with base_syntax as default;
wenzelm
parents:
59073
diff
changeset
|
115 |
else new Outer_Syntax(keywords1, completion1, language_context, has_tokens) |
59073 | 116 |
} |
117 |
||
118 |
||
59735 | 119 |
/* load commands */ |
58900 | 120 |
|
63441 | 121 |
def load_command(name: String): Option[List[String]] = keywords.load_commands.get(name) |
58900 | 122 |
def load_commands_in(text: String): Boolean = keywords.load_commands_in(text) |
123 |
||
124 |
||
58706 | 125 |
/* language context */ |
34166 | 126 |
|
58706 | 127 |
def set_language_context(context: Completion.Language_Context): Outer_Syntax = |
58900 | 128 |
new Outer_Syntax(keywords, completion, context, has_tokens) |
58706 | 129 |
|
130 |
def no_tokens: Outer_Syntax = |
|
46969 | 131 |
{ |
58900 | 132 |
require(keywords.is_empty) |
58706 | 133 |
new Outer_Syntax( |
134 |
completion = completion, |
|
135 |
language_context = language_context, |
|
136 |
has_tokens = false) |
|
46969 | 137 |
} |
40454
2516ea25a54b
some support for nested source structure, based on section headings;
wenzelm
parents:
38471
diff
changeset
|
138 |
|
58706 | 139 |
|
40454
2516ea25a54b
some support for nested source structure, based on section headings;
wenzelm
parents:
38471
diff
changeset
|
140 |
|
58706 | 141 |
/** parsing **/ |
34166 | 142 |
|
58697 | 143 |
/* line-oriented structure */ |
58696 | 144 |
|
59924
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
145 |
def line_structure(tokens: List[Token], structure: Outer_Syntax.Line_Structure) |
58700 | 146 |
: Outer_Syntax.Line_Structure = |
58696 | 147 |
{ |
58700 | 148 |
val improper1 = tokens.forall(_.is_improper) |
149 |
val command1 = tokens.exists(_.is_command) |
|
150 |
||
58696 | 151 |
val depth1 = |
63424 | 152 |
if (tokens.exists(keywords.is_command(_, Keyword.theory))) 0 |
59924
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
153 |
else if (command1) structure.after_span_depth |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
154 |
else structure.span_depth |
58700 | 155 |
|
156 |
val (span_depth1, after_span_depth1) = |
|
59924
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
157 |
((structure.span_depth, structure.after_span_depth) /: tokens) { |
58703 | 158 |
case ((x, y), tok) => |
159 |
if (tok.is_command) { |
|
63424 | 160 |
if (keywords.is_command(tok, Keyword.theory_goal)) (2, 1) |
161 |
else if (keywords.is_command(tok, Keyword.theory)) (1, 0) |
|
162 |
else if (keywords.is_command(tok, Keyword.proof_open)) (y + 2, y + 1) |
|
163 |
else if (keywords.is_command(tok, Keyword.PRF_BLOCK == _)) (y + 2, y + 1) |
|
164 |
else if (keywords.is_command(tok, Keyword.QED_BLOCK == _)) (y + 1, y - 2) |
|
165 |
else if (keywords.is_command(tok, Keyword.proof_close)) (y + 1, y - 1) |
|
166 |
else if (keywords.is_command(tok, Keyword.qed_global)) (1, 0) |
|
58703 | 167 |
else (x, y) |
168 |
} |
|
169 |
else (x, y) |
|
58696 | 170 |
} |
58700 | 171 |
|
172 |
Outer_Syntax.Line_Structure(improper1, command1, depth1, span_depth1, after_span_depth1) |
|
58696 | 173 |
} |
174 |
||
175 |
||
58706 | 176 |
/* command spans */ |
57905
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
177 |
|
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
178 |
def parse_spans(toks: List[Token]): List[Command_Span.Span] = |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
179 |
{ |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
180 |
val result = new mutable.ListBuffer[Command_Span.Span] |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
181 |
val content = new mutable.ListBuffer[Token] |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
182 |
val improper = new mutable.ListBuffer[Token] |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
183 |
|
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
184 |
def ship(span: List[Token]) |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
185 |
{ |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
186 |
val kind = |
59924
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
187 |
if (span.forall(_.is_improper)) Command_Span.Ignored_Span |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
188 |
else if (span.exists(_.is_error)) Command_Span.Malformed_Span |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
189 |
else |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
190 |
span.find(_.is_command) match { |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
191 |
case None => Command_Span.Malformed_Span |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
192 |
case Some(cmd) => |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
193 |
val name = cmd.source |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
194 |
val offset = |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
195 |
(0 /: span.takeWhile(_ != cmd)) { |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
196 |
case (i, tok) => i + Symbol.iterator(tok.source).length } |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
197 |
val end_offset = offset + Symbol.iterator(name).length |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
198 |
val pos = Position.Range(Text.Range(offset, end_offset) + 1) |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
199 |
Command_Span.Command_Span(name, pos) |
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
200 |
} |
57905
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
201 |
result += Command_Span.Span(kind, span) |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
202 |
} |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
203 |
|
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
204 |
def flush() |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
205 |
{ |
59319 | 206 |
if (content.nonEmpty) { ship(content.toList); content.clear } |
207 |
if (improper.nonEmpty) { ship(improper.toList); improper.clear } |
|
57905
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
208 |
} |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
209 |
|
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
210 |
for (tok <- toks) { |
59924
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
211 |
if (tok.is_improper) improper += tok |
63441 | 212 |
else if (keywords.is_before_command(tok) || |
213 |
tok.is_command && |
|
214 |
(!content.exists(keywords.is_before_command(_)) || content.exists(_.is_command))) |
|
59924
801b979ec0c2
more general notion of command span: command keyword not necessarily at start;
wenzelm
parents:
59735
diff
changeset
|
215 |
{ flush(); content += tok } |
57905
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
216 |
else { content ++= improper; improper.clear; content += tok } |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
217 |
} |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
218 |
flush() |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
219 |
|
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
220 |
result.toList |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
221 |
} |
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
222 |
|
57906 | 223 |
def parse_spans(input: CharSequence): List[Command_Span.Span] = |
59083 | 224 |
parse_spans(Token.explode(keywords, input)) |
57906 | 225 |
|
57905
c0c5652e796e
separate module Command_Span: mostly syntactic representation;
wenzelm
parents:
57901
diff
changeset
|
226 |
|
58706 | 227 |
/* overall document structure */ |
55616 | 228 |
|
58706 | 229 |
def heading_level(command: Command): Option[Int] = |
230 |
{ |
|
59735 | 231 |
val name = command.span.name |
232 |
name match { |
|
233 |
case Thy_Header.CHAPTER => Some(0) |
|
62453 | 234 |
case Thy_Header.SECTION => Some(1) |
59735 | 235 |
case Thy_Header.SUBSECTION => Some(2) |
236 |
case Thy_Header.SUBSUBSECTION => Some(3) |
|
61463 | 237 |
case Thy_Header.PARAGRAPH => Some(4) |
238 |
case Thy_Header.SUBPARAGRAPH => Some(5) |
|
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
239 |
case _ => |
63441 | 240 |
keywords.kinds.get(name) match { |
61463 | 241 |
case Some(kind) if Keyword.theory(kind) && !Keyword.theory_end(kind) => Some(6) |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
242 |
case _ => None |
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
243 |
} |
58706 | 244 |
} |
245 |
} |
|
246 |
||
58743 | 247 |
def parse_document(node_name: Document.Node.Name, text: CharSequence): |
248 |
List[Outer_Syntax.Document] = |
|
58706 | 249 |
{ |
250 |
/* stack operations */ |
|
251 |
||
252 |
def buffer(): mutable.ListBuffer[Outer_Syntax.Document] = |
|
253 |
new mutable.ListBuffer[Outer_Syntax.Document] |
|
254 |
||
58747 | 255 |
var stack: List[(Int, Command, mutable.ListBuffer[Outer_Syntax.Document])] = |
256 |
List((0, Command.empty, buffer())) |
|
55616 | 257 |
|
58706 | 258 |
@tailrec def close(level: Int => Boolean) |
259 |
{ |
|
260 |
stack match { |
|
58747 | 261 |
case (lev, command, body) :: (_, _, body2) :: rest if level(lev) => |
59735 | 262 |
body2 += Outer_Syntax.Document_Block(command.span.name, command.source, body.toList) |
58706 | 263 |
stack = stack.tail |
264 |
close(level) |
|
265 |
case _ => |
|
266 |
} |
|
267 |
} |
|
268 |
||
58743 | 269 |
def result(): List[Outer_Syntax.Document] = |
58706 | 270 |
{ |
271 |
close(_ => true) |
|
58743 | 272 |
stack.head._3.toList |
58706 | 273 |
} |
274 |
||
275 |
def add(command: Command) |
|
276 |
{ |
|
277 |
heading_level(command) match { |
|
278 |
case Some(i) => |
|
279 |
close(_ > i) |
|
58747 | 280 |
stack = (i + 1, command, buffer()) :: stack |
58706 | 281 |
case None => |
282 |
} |
|
283 |
stack.head._3 += Outer_Syntax.Document_Atom(command) |
|
284 |
} |
|
285 |
||
286 |
||
287 |
/* result structure */ |
|
288 |
||
289 |
val spans = parse_spans(text) |
|
59702
58dfaa369c11
hybrid use of command blobs: inlined errors and auxiliary files;
wenzelm
parents:
59700
diff
changeset
|
290 |
spans.foreach(span => add(Command(Document_ID.none, node_name, Command.no_blobs, span))) |
58706 | 291 |
result() |
55616 | 292 |
} |
34166 | 293 |
} |