1404 val _ = if |
1404 val _ = if |
1405 in |
1405 in |
1406 thy |
1406 thy |
1407 end;*) |
1407 end;*) |
1408 |
1408 |
|
1409 fun read_class thy raw_class = |
|
1410 let |
|
1411 val class = Sign.intern_class thy raw_class; |
|
1412 val _ = AxClass.get_definition thy class; |
|
1413 in class end; |
|
1414 |
1409 fun read_type thy raw_tyco = |
1415 fun read_type thy raw_tyco = |
1410 let |
1416 let |
1411 val tyco = Sign.intern_type thy raw_tyco; |
1417 val tyco = Sign.intern_type thy raw_tyco; |
1412 val _ = if Sign.declared_tyname thy tyco then () |
1418 val _ = if Sign.declared_tyname thy tyco then () |
1413 else error ("No such type constructor: " ^ quote raw_tyco); |
1419 else error ("No such type constructor: " ^ quote raw_tyco); |
1417 let |
1423 let |
1418 val cs' = AList.make (fn c => Sign.the_const_type thy c) cs; |
1424 val cs' = AList.make (fn c => Sign.the_const_type thy c) cs; |
1419 val cs'' = map (CodegenConsts.norm_of_typ thy) cs'; |
1425 val cs'' = map (CodegenConsts.norm_of_typ thy) cs'; |
1420 in AList.make (CodegenNames.const thy) cs'' end; |
1426 in AList.make (CodegenNames.const thy) cs'' end; |
1421 |
1427 |
1422 val add_syntax_class = gen_add_syntax_class ClassPackage.read_class CodegenConsts.read_const; |
1428 val add_syntax_class = gen_add_syntax_class read_class CodegenConsts.read_const; |
1423 val add_syntax_inst = gen_add_syntax_inst ClassPackage.read_class read_type; |
1429 val add_syntax_inst = gen_add_syntax_inst read_class read_type; |
1424 val add_syntax_tyco = gen_add_syntax_tyco read_type; |
1430 val add_syntax_tyco = gen_add_syntax_tyco read_type; |
1425 val add_syntax_const = gen_add_syntax_const CodegenConsts.read_const; |
1431 val add_syntax_const = gen_add_syntax_const CodegenConsts.read_const; |
1426 |
1432 |
1427 fun add_reserved target = |
1433 fun add_reserved target = |
1428 map_reserveds target o insert (op =); |
1434 map_reserveds target o insert (op =); |
1556 val _ = OuterSyntax.add_parsers [code_classP, code_instanceP, code_typeP, code_constP, |
1562 val _ = OuterSyntax.add_parsers [code_classP, code_instanceP, code_typeP, code_constP, |
1557 code_reservedP, code_modulenameP, code_moduleprologP]; |
1563 code_reservedP, code_modulenameP, code_moduleprologP]; |
1558 |
1564 |
1559 val _ = Context.add_setup ( |
1565 val _ = Context.add_setup ( |
1560 gen_add_syntax_tyco (K I) "SML" "fun" (SOME (2, fn fxy => fn pr_typ => fn [ty1, ty2] => |
1566 gen_add_syntax_tyco (K I) "SML" "fun" (SOME (2, fn fxy => fn pr_typ => fn [ty1, ty2] => |
1561 (gen_brackify (case fxy of BR => false | _ => eval_fxy (INFX (1, R)) fxy) o Pretty.breaks) [ |
1567 (gen_brackify (case fxy of NOBR => false | _ => eval_fxy (INFX (1, R)) fxy) o Pretty.breaks) [ |
1562 pr_typ (INFX (1, X)) ty1, |
1568 pr_typ (INFX (1, X)) ty1, |
1563 str "->", |
1569 str "->", |
1564 pr_typ (INFX (1, R)) ty2 |
1570 pr_typ (INFX (1, R)) ty2 |
1565 ])) |
1571 ])) |
1566 #> gen_add_syntax_tyco (K I) "Haskell" "fun" (SOME (2, fn fxy => fn pr_typ => fn [ty1, ty2] => |
1572 #> gen_add_syntax_tyco (K I) "Haskell" "fun" (SOME (2, fn fxy => fn pr_typ => fn [ty1, ty2] => |