diff -r 74f0a06f751f -r d69214e47ef9 ProgTutorial/antiquote_setup.ML --- a/ProgTutorial/antiquote_setup.ML Thu Aug 20 22:30:20 2009 +0200 +++ b/ProgTutorial/antiquote_setup.ML Thu Aug 20 23:30:51 2009 +0200 @@ -87,6 +87,7 @@ val single_arg = Scan.lift (Args.name) val two_args = Scan.lift (Args.name -- Args.name) +val test = Scan.lift (Args.name -- Args.name -- Scan.option (Args.$$$ "with" |-- Args.name)) val _ = ThyOutput.antiquotation "ML" parser_ml output_ml val _ = ThyOutput.antiquotation "ML_ind" parser_ml_ind output_ml_ind @@ -98,6 +99,19 @@ val _ = ThyOutput.antiquotation "ML_response_fake" two_args output_response_fake val _ = ThyOutput.antiquotation "ML_response_fake_both" two_args ouput_response_fake_both +(* FIXME: experimental *) +fun ml_eq (lhs, pat, eq) = + implode ["val true = ((", eq, ") (", lhs, ",", pat, "))"] + +fun output_response_eq {context = ctxt, ...} ((lhs, pat), eq) = + (case eq of + NONE => eval_fn ctxt (ml_pat (lhs, pat)) + | SOME e => eval_fn ctxt (ml_eq (lhs, pat, e)); + output ((prefix_lines "" lhs) @ (prefix_lines "> " pat))) + +val _ = ThyOutput.antiquotation "ML_response_eq" test output_response_eq + +(* checks whether a file exists in the Isabelle distribution *) fun href_link txt = let val raw = Symbol.encode_raw @@ -106,13 +120,11 @@ implode [raw "\\href{", raw path, raw txt, raw "}{", txt, raw "}"] end -(* checks whether a file exists in the Isabelle distribution *) fun check_file_exists _ txt = (if File.exists (Path.append (Path.explode ("~~/src")) (Path.explode txt)) then output [href_link txt] else error (implode ["Source file ", quote txt, " does not exist."])) - val _ = ThyOutput.antiquotation "ML_file" single_arg check_file_exists