142 /* make commands */ |
142 /* make commands */ |
143 |
143 |
144 def name(span: List[Token]): String = |
144 def name(span: List[Token]): String = |
145 span.find(_.is_command) match { case Some(tok) => tok.source case _ => "" } |
145 span.find(_.is_command) match { case Some(tok) => tok.source case _ => "" } |
146 |
146 |
|
147 type Blobs = List[(Document.Node.Name, Option[SHA1.Digest])] |
|
148 |
147 def apply( |
149 def apply( |
148 id: Document_ID.Command, |
150 id: Document_ID.Command, |
149 node_name: Document.Node.Name, |
151 node_name: Document.Node.Name, |
150 span: List[Token], |
152 span: List[Token], |
151 thy_load: Option[List[String]], |
153 blobs: Blobs, |
152 results: Results = Results.empty, |
154 results: Results = Results.empty, |
153 markup: Markup_Tree = Markup_Tree.empty): Command = |
155 markup: Markup_Tree = Markup_Tree.empty): Command = |
154 { |
156 { |
155 val source: String = |
157 val source: String = |
156 span match { |
158 span match { |
165 val s1 = source.substring(i, i + n) |
167 val s1 = source.substring(i, i + n) |
166 span1 += Token(kind, s1) |
168 span1 += Token(kind, s1) |
167 i += n |
169 i += n |
168 } |
170 } |
169 |
171 |
170 new Command(id, node_name, span1.toList, source, thy_load, results, markup) |
172 new Command(id, node_name, span1.toList, source, blobs, results, markup) |
171 } |
173 } |
172 |
174 |
173 val empty = Command(Document_ID.none, Document.Node.Name.empty, Nil, None) |
175 val empty = Command(Document_ID.none, Document.Node.Name.empty, Nil, Nil) |
174 |
176 |
175 def unparsed(id: Document_ID.Command, source: String, results: Results, markup: Markup_Tree) |
177 def unparsed(id: Document_ID.Command, source: String, results: Results, markup: Markup_Tree) |
176 : Command = |
178 : Command = |
177 Command(id, Document.Node.Name.empty, List(Token(Token.Kind.UNPARSED, source)), None, |
179 Command(id, Document.Node.Name.empty, List(Token(Token.Kind.UNPARSED, source)), Nil, |
178 results, markup) |
180 results, markup) |
179 |
181 |
180 def unparsed(source: String): Command = |
182 def unparsed(source: String): Command = |
181 unparsed(Document_ID.none, source, Results.empty, Markup_Tree.empty) |
183 unparsed(Document_ID.none, source, Results.empty, Markup_Tree.empty) |
182 |
184 |
213 final class Command private( |
215 final class Command private( |
214 val id: Document_ID.Command, |
216 val id: Document_ID.Command, |
215 val node_name: Document.Node.Name, |
217 val node_name: Document.Node.Name, |
216 val span: List[Token], |
218 val span: List[Token], |
217 val source: String, |
219 val source: String, |
218 val thy_load: Option[List[String]], |
220 val blobs: Command.Blobs, |
219 val init_results: Command.Results, |
221 val init_results: Command.Results, |
220 val init_markup: Markup_Tree) |
222 val init_markup: Markup_Tree) |
221 { |
223 { |
222 /* classification */ |
224 /* classification */ |
223 |
225 |