47 val opt_infix: token list -> string * token list |
47 val opt_infix: token list -> string * token list |
48 val opt_mixfix: token list -> string * token list |
48 val opt_mixfix: token list -> string * token list |
49 type syntax |
49 type syntax |
50 val make_syntax: string list -> |
50 val make_syntax: string list -> |
51 (string * (token list -> (string * string) * token list)) list -> syntax |
51 (string * (token list -> (string * string) * token list)) list -> syntax |
52 val parse_thy: syntax -> string -> string |
52 val parse_thy: syntax -> string -> string -> string |
53 val section: string -> string -> (token list -> string * token list) |
53 val section: string -> string -> (token list -> string * token list) |
54 -> (string * (token list -> (string * string) * token list)) |
54 -> (string * (token list -> (string * string) * token list)) |
55 val axm_section: string -> string |
55 val axm_section: string -> string |
56 -> (token list -> (string * string list) * token list) |
56 -> (token list -> (string * string list) * token list) |
57 -> (string * (token list -> (string * string) * token list)) |
57 -> (string * (token list -> (string * string) * token list)) |
386 optional ("ML" $$-- verbatim) "" >> mk_extension; |
386 optional ("ML" $$-- verbatim) "" >> mk_extension; |
387 |
387 |
388 |
388 |
389 (* theory definition *) |
389 (* theory definition *) |
390 |
390 |
391 fun mk_structure ((thy_name, old_thys), Some (extxt, postxt, mltxt)) = |
391 fun mk_structure tname ((thy_name, old_thys), Some (extxt, postxt, mltxt)) = |
392 "structure " ^ thy_name ^ " =\n\ |
392 if (thy_name = tname) then |
393 \struct\n\ |
393 "structure " ^ thy_name ^ " =\n\ |
394 \\n\ |
394 \struct\n\ |
395 \local\n" |
395 \\n\ |
396 ^ trfun_defs ^ "\n\ |
396 \local\n" |
397 \in\n\ |
397 ^ trfun_defs ^ "\n\ |
398 \\n" |
398 \in\n\ |
399 ^ mltxt ^ "\n\ |
399 \\n" |
400 \\n\ |
400 ^ mltxt ^ "\n\ |
401 \val thy = (" ^ old_thys ^ " true)\n\n\ |
401 \\n\ |
402 \|> add_trfuns\n" |
402 \val thy = (" ^ old_thys ^ " true)\n\n\ |
403 ^ trfun_args ^ "\n\ |
403 \|> add_trfuns\n" |
404 \\n" |
404 ^ trfun_args ^ "\n\ |
405 ^ extxt ^ "\n\ |
405 \\n" |
406 \\n\ |
406 ^ extxt ^ "\n\ |
407 \|> add_thyname " ^ quote thy_name ^ ";\n\ |
407 \\n\ |
408 \\n\ |
408 \|> add_thyname " ^ quote thy_name ^ ";\n\ |
409 \\n" |
409 \\n\ |
410 ^ postxt ^ "\n\ |
410 \\n" |
411 \\n\ |
411 ^ postxt ^ "\n\ |
412 \end;\n\ |
412 \\n\ |
413 \end;\n" |
413 \end;\n\ |
414 | mk_structure ((thy_name, old_thys), None) = |
414 \end;\n" |
415 "structure " ^ thy_name ^ " =\n\ |
415 else error ("use_thy: Filename \"" ^ tname ^ ".thy\" and theory name \"" |
416 \struct\n\ |
416 ^ thy_name ^ "\" are different") |
417 \\n\ |
417 | mk_structure tname ((thy_name, old_thys), None) = |
418 \val thy = (" ^ old_thys ^ " false);\n\ |
418 if (thy_name = tname) then |
419 \\n\ |
419 "structure " ^ thy_name ^ " =\n\ |
420 \end;\n"; |
420 \struct\n\ |
421 |
421 \\n\ |
422 fun theory_defn sectab = |
422 \val thy = (" ^ old_thys ^ " false);\n\ |
|
423 \\n\ |
|
424 \end;\n" |
|
425 else error ("use_thy: Filename \"" ^ tname ^ ".thy\" and theory name \"" |
|
426 ^ thy_name ^ "\" are different"); |
|
427 |
|
428 fun theory_defn sectab tname = |
423 header -- optional (extension sectab >> Some) None -- eof |
429 header -- optional (extension sectab >> Some) None -- eof |
424 >> (mk_structure o #1); |
430 >> (mk_structure tname o #1); |
425 |
431 |
426 fun parse_thy (lex, sectab) str = |
432 fun parse_thy (lex, sectab) tname str = |
427 #1 (!! (theory_defn sectab) (tokenize lex str)); |
433 #1 (!! (theory_defn sectab tname) (tokenize lex str)); |
428 |
434 |
429 |
435 |
430 (* standard sections *) |
436 (* standard sections *) |
431 |
437 |
432 fun mk_val ax = "val " ^ ax ^ " = get_axiom thy " ^ quote ax ^ ";"; |
438 fun mk_val ax = "val " ^ ax ^ " = get_axiom thy " ^ quote ax ^ ";"; |