changeset 34900 | 9b12b0824bfe |
parent 34888 | 460ec1a99aa2 |
child 34944 | 970e1466028d |
34899:8674bb6f727b | 34900:9b12b0824bfe |
---|---|
69 val (no_syntax, print') = case syntax_const c |
69 val (no_syntax, print') = case syntax_const c |
70 of NONE => (true, fn ts => applify "(" ")" fxy |
70 of NONE => (true, fn ts => applify "(" ")" fxy |
71 (applify "[" "]" NOBR ((str o deresolve) c) (map (print_typ tyvars NOBR) tys')) |
71 (applify "[" "]" NOBR ((str o deresolve) c) (map (print_typ tyvars NOBR) tys')) |
72 (map (print_term tyvars is_pat thm vars NOBR) ts)) |
72 (map (print_term tyvars is_pat thm vars NOBR) ts)) |
73 | SOME (_, print) => (false, fn ts => |
73 | SOME (_, print) => (false, fn ts => |
74 print (print_term tyvars is_pat thm) thm vars fxy (ts ~~ take k tys_args)); |
74 print (print_term tyvars is_pat thm) thm vars fxy (ts ~~ take l tys_args)); |
75 in if k = l then print' ts |
75 in if k = l then print' ts |
76 else if k < l then |
76 else if k < l then |
77 print_term tyvars is_pat thm vars fxy (Code_Thingol.eta_expand l app) |
77 print_term tyvars is_pat thm vars fxy (Code_Thingol.eta_expand l app) |
78 else let |
78 else let |
79 val (ts1, ts23) = chop l ts; |
79 val (ts1, ts23) = chop l ts; |
402 val literals = let |
402 val literals = let |
403 fun char_scala c = |
403 fun char_scala c = |
404 let |
404 let |
405 val s = ML_Syntax.print_char c; |
405 val s = ML_Syntax.print_char c; |
406 in if s = "'" then "\\'" else s end; |
406 in if s = "'" then "\\'" else s end; |
407 fun bigint_scala k = "(" ^ (if k <= 2147483647 |
|
408 then string_of_int k else quote (string_of_int k)) ^ ")" |
|
407 in Literals { |
409 in Literals { |
408 literal_char = Library.enclose "'" "'" o char_scala, |
410 literal_char = Library.enclose "'" "'" o char_scala, |
409 literal_string = quote o translate_string char_scala, |
411 literal_string = quote o translate_string char_scala, |
410 literal_numeral = fn unbounded => fn k => if k >= 0 then string_of_int k |
412 literal_numeral = fn unbounded => fn k => if k >= 0 then |
411 else Library.enclose "(" ")" (signed_string_of_int k), |
413 if unbounded then bigint_scala k |
414 else Library.enclose "(" ")" (string_of_int k) |
|
415 else |
|
416 if unbounded then "(- " ^ bigint_scala (~ k) ^ ")" |
|
417 else Library.enclose "(" ")" (signed_string_of_int k), |
|
412 literal_list = fn [] => str "Nil" | ps => Pretty.block [str "List", enum "," "(" ")" ps], |
418 literal_list = fn [] => str "Nil" | ps => Pretty.block [str "List", enum "," "(" ")" ps], |
413 infix_cons = (6, "::") |
419 infix_cons = (6, "::") |
414 } end; |
420 } end; |
415 |
421 |
416 |
422 |
422 |
428 |
423 val setup = |
429 val setup = |
424 Code_Target.add_target (target, (isar_seri_scala, literals)) |
430 Code_Target.add_target (target, (isar_seri_scala, literals)) |
425 #> Code_Target.add_syntax_tyco target "fun" (SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] => |
431 #> Code_Target.add_syntax_tyco target "fun" (SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] => |
426 brackify_infix (1, R) fxy [ |
432 brackify_infix (1, R) fxy [ |
427 print_typ (INFX (1, X)) ty1, |
433 print_typ BR ty1 (*product type vs. tupled arguments!*), |
428 str "=>", |
434 str "=>", |
429 print_typ (INFX (1, R)) ty2 |
435 print_typ (INFX (1, R)) ty2 |
430 ])) |
436 ])) |
431 #> fold (Code_Target.add_reserved target) [ |
437 #> fold (Code_Target.add_reserved target) [ |
432 "abstract", "case", "catch", "class", "def", "do", "else", "extends", "false", |
438 "abstract", "case", "catch", "class", "def", "do", "else", "extends", "false", |