175 SOME (Command {command_parser = Parser parse, ...}) => |
175 SOME (Command {command_parser = Parser parse, ...}) => |
176 Parse.!!! (command_tags |-- parse) >> (fn f => f tr0) |
176 Parse.!!! (command_tags |-- parse) >> (fn f => f tr0) |
177 | SOME (Command {command_parser = Limited_Parser parse, ...}) => |
177 | SOME (Command {command_parser = Limited_Parser parse, ...}) => |
178 before_command :|-- (fn limited => |
178 before_command :|-- (fn limited => |
179 Parse.!!! (command_tags |-- parse limited)) >> (fn f => f tr0) |
179 Parse.!!! (command_tags |-- parse limited)) >> (fn f => f tr0) |
180 | NONE => |
180 | NONE => Scan.fail_with (fn _ => fn _ => err_command "Undefined command " name [pos])) |
181 Scan.succeed |
|
182 (tr0 |> Toplevel.imperative (fn () => err_command "Undefined command " name [pos]))) |
|
183 end); |
181 end); |
184 |
182 |
185 val parse_cmt = Parse.$$$ "--" -- Parse.!!! Parse.document_source; |
183 val parse_cmt = Parse.$$$ "--" -- Parse.!!! Parse.document_source; |
186 |
|
187 in |
|
188 |
184 |
189 fun commands_source thy = |
185 fun commands_source thy = |
190 Token.source_proper #> |
186 Token.source_proper #> |
191 Source.source Token.stopper (Scan.bulk (parse_cmt >> K NONE || Parse.not_eof >> SOME)) #> |
187 Source.source Token.stopper (Scan.bulk (parse_cmt >> K NONE || Parse.not_eof >> SOME)) #> |
192 Source.map_filter I #> |
188 Source.map_filter I #> |
193 Source.source Token.stopper (Scan.bulk (fn xs => Parse.!!! (parse_command thy) xs)); |
189 Source.source Token.stopper (Scan.bulk (fn xs => Parse.!!! (parse_command thy) xs)); |
194 |
190 |
195 end; |
191 in |
196 |
192 |
197 fun parse thy pos str = |
193 fun parse thy pos str = |
198 Source.of_string str |
194 Source.of_string str |
199 |> Symbol.source |
195 |> Symbol.source |
200 |> Token.source (Thy_Header.get_keywords thy) pos |
196 |> Token.source (Thy_Header.get_keywords thy) pos |