diff -r be23597e81db -r f875a25aa72d ProgTutorial/Recipes/Antiquotes.thy --- a/ProgTutorial/Recipes/Antiquotes.thy Fri May 17 07:29:51 2019 +0200 +++ b/ProgTutorial/Recipes/Antiquotes.thy Fri May 17 10:38:01 2019 +0200 @@ -31,11 +31,10 @@ We first describe the antiquotation \ML_checked\ with the syntax: - @{text [display] "@{ML_checked \"a_piece_of_code\"}"} + @{text [display] \@{ML_checked "a_piece_of_code"}\} The code is checked by sending the ML-expression @{text [quotes] "val _ = - a_piece_of_code"} to the ML-compiler (i.e.~the function @{ML - "ML_Context.eval_source_in"} in Line 7 below). The complete code of the + a_piece_of_code"} to the ML-compiler (i.e.~the function @{ML \ML_Context.eval_source_in\} in Line 7 below). The complete code of the document antiquotation is as follows: \ @@ -58,26 +57,26 @@ text \ - The parser @{ML "(Scan.lift Args.name)"} in Line 7 parses a string, in this + The parser @{ML \(Scan.lift Args.name)\} in Line 7 parses a string, in this case the code, and then calls the function @{ML output_ml}. As mentioned before, the parsed code is sent to the ML-compiler in Line 4 using the function @{ML ml_val}, which constructs the appropriate ML-expression, and - using @{ML "eval_in" in ML_Context}, which calls the compiler. If the code is - ``approved'' by the compiler, then the output function @{ML "output" in + using @{ML \eval_in\ in ML_Context}, which calls the compiler. If the code is + ``approved'' by the compiler, then the output function @{ML \output\ in Document_Antiquotation} in the next line pretty prints the code. This function expects that the code is a list of (pretty)strings where each string correspond to a - line in the output. Therefore the use of @{ML "(space_explode \"\\n\" txt)" + line in the output. Therefore the use of @{ML \(space_explode "\\n" txt)\ for txt} which produces such a list according to linebreaks. There are a number of options for antiquotations that are observed by the function - @{ML "output" in Document_Antiquotation} when printing the code (including \[display]\ - and \[quotes]\). The function @{ML "antiquotation_raw" in Thy_Output} in + @{ML \output\ in Document_Antiquotation} when printing the code (including \[display]\ + and \[quotes]\). The function @{ML \antiquotation_raw\ in Thy_Output} in Line 7 sets up the new document antiquotation. \begin{readmore} For more information about options of document antiquotations see \rsccite{sec:antiq}). \end{readmore} - Since we used the argument @{ML "Position.none"}, the compiler cannot give specific + Since we used the argument @{ML \Position.none\}, the compiler cannot give specific information about the line number, in case an error is detected. We can improve the code above slightly by writing \ @@ -116,7 +115,7 @@ going to implement the document antiquotation: - @{text [display] "@{ML_resp \"a_piece_of_code\" \"a_pattern\"}"} + @{text [display] \@{ML_resp "a_piece_of_code" "a_pattern"}\} To add some convenience and also to deal with large outputs, the user can give a partial specification by using ellipses. For example \(\, \)\ @@ -193,7 +192,7 @@ the output (Lines 4 to 7) and the parser in the setup (Line 11). Now you can write - @{text [display] "@{ML_resp [display] \"true andalso false\" \"false\"}"} + @{text [display] \@{ML_resp [display] "true andalso false" "false"}\} to obtain @@ -201,7 +200,7 @@ or - @{text [display] "@{ML_resp [display] \"let val i = 3 in (i * i, \"foo\") end\" \"(9, \)\"}"} + @{text [display] \@{ML_resp [display] "let val i = 3 in (i * i, "foo") end" "(9, \)"}\} to obtain