# HG changeset patch # User wenzelm # Date 1515254167 -3600 # Node ID 5f7f339f3d7e8e56baaaa74600441e2e4ac4a9f1 # Parent 1f1d85393d70513c3de64c37c1c12377538fea97 inner syntax comments may be written as "\ \text\"; diff -r 1f1d85393d70 -r 5f7f339f3d7e NEWS --- a/NEWS Sat Jan 06 15:08:42 2018 +0100 +++ b/NEWS Sat Jan 06 16:56:07 2018 +0100 @@ -9,6 +9,9 @@ *** General *** +* Inner syntax comments may be written as "\ \text\", similar to +marginal comments in outer syntax. + * The old 'def' command has been discontinued (legacy since Isbelle2016-1). INCOMPATIBILITY, use 'define' instead -- usually with object-logic equality or equivalence. diff -r 1f1d85393d70 -r 5f7f339f3d7e src/Doc/Isar_Ref/Inner_Syntax.thy --- a/src/Doc/Isar_Ref/Inner_Syntax.thy Sat Jan 06 15:08:42 2018 +0100 +++ b/src/Doc/Isar_Ref/Inner_Syntax.thy Sat Jan 06 16:56:07 2018 +0100 @@ -565,6 +565,7 @@ @{syntax_def (inner) str_token} & = & \<^verbatim>\''\ \\\ \<^verbatim>\''\ \\ @{syntax_def (inner) string_token} & = & \<^verbatim>\"\ \\\ \<^verbatim>\"\ \\ @{syntax_def (inner) cartouche} & = & @{verbatim "\"} \\\ @{verbatim "\"} \\ + @{syntax_def (inner) comment_cartouche} & = & @{verbatim "\ \"} \\\ @{verbatim "\"} \\ \end{supertabular} \end{center} @@ -578,6 +579,11 @@ The derived categories @{syntax_def (inner) num_const}, and @{syntax_def (inner) float_const}, provide robust access to the respective tokens: the syntax tree holds a syntactic constant instead of a free variable. + + A @{syntax (inner) comment_cartouche} resembles the outer syntax notation + for marginal @{syntax_ref comment} (\secref{sec:comments}), but is + syntactically more restrictive: only the symbol-form with \<^verbatim>\\\ and text + cartouche is supported. \ diff -r 1f1d85393d70 -r 5f7f339f3d7e src/Pure/Syntax/lexicon.ML --- a/src/Pure/Syntax/lexicon.ML Sat Jan 06 15:08:42 2018 +0100 +++ b/src/Pure/Syntax/lexicon.ML Sat Jan 06 16:56:07 2018 +0100 @@ -21,8 +21,8 @@ val scan_tvar: Symbol_Pos.T list -> Symbol_Pos.T list * Symbol_Pos.T list val is_tid: string -> bool datatype token_kind = - Literal | IdentSy | LongIdentSy | VarSy | TFreeSy | TVarSy | NumSy | - FloatSy | StrSy | StringSy | Cartouche | Space | Comment | EOF + Literal | IdentSy | LongIdentSy | VarSy | TFreeSy | TVarSy | NumSy | FloatSy | + StrSy | StringSy | Cartouche | Space | Comment | Comment_Cartouche| EOF datatype token = Token of token_kind * string * Position.range val str_of_token: token -> string val pos_of_token: token -> Position.T @@ -112,8 +112,8 @@ (** datatype token **) datatype token_kind = - Literal | IdentSy | LongIdentSy | VarSy | TFreeSy | TVarSy | NumSy | - FloatSy | StrSy | StringSy | Cartouche | Space | Comment | EOF; + Literal | IdentSy | LongIdentSy | VarSy | TFreeSy | TVarSy | NumSy | FloatSy | StrSy | + StringSy | Cartouche | Space | Comment | Comment_Cartouche | EOF; datatype token = Token of token_kind * string * Position.range; @@ -122,6 +122,7 @@ fun is_proper (Token (Space, _, _)) = false | is_proper (Token (Comment, _, _)) = false + | is_proper (Token (Comment_Cartouche, _, _)) = false | is_proper _ = true; @@ -170,6 +171,7 @@ | StringSy => Markup.inner_string | Cartouche => Markup.inner_cartouche | Comment => Markup.inner_comment + | Comment_Cartouche => Markup.inner_comment | _ => Markup.empty; fun report_of_token (Token (kind, s, (pos, _))) = @@ -244,6 +246,12 @@ val explode_str = explode_literal scan_str_body; +(* comment cartouche *) + +val scan_comment_cartouche = + $$$ "\" @@@ Scan.many (Symbol.is_blank o Symbol_Pos.symbol) @@@ + !!! "cartouche expected after \"\\"" (Symbol_Pos.scan_cartouche err_prefix); + (** tokenize **) @@ -270,6 +278,7 @@ val scan_token = Symbol_Pos.scan_cartouche err_prefix >> token Cartouche || Symbol_Pos.scan_comment err_prefix >> token Comment || + scan_comment_cartouche >> token Comment_Cartouche || Scan.max token_leq scan_lit scan_val || scan_string >> token StringSy || scan_str >> token StrSy ||