src/Pure/Isar/token.ML
changeset 56202 0a11d17eeeff
parent 56064 7658489047e3
child 57942 e5bec882fdd0
equal deleted inserted replaced
56201:dd2df97b379b 56202:0a11d17eeeff
    10     Command | Keyword | Ident | LongIdent | SymIdent | Var | TypeIdent | TypeVar |
    10     Command | Keyword | Ident | LongIdent | SymIdent | Var | TypeIdent | TypeVar |
    11     Nat | Float | String | AltString | Verbatim | Cartouche | Space | Comment | InternalValue |
    11     Nat | Float | String | AltString | Verbatim | Cartouche | Space | Comment | InternalValue |
    12     Error of string | Sync | EOF
    12     Error of string | Sync | EOF
    13   type file = {src_path: Path.T, lines: string list, digest: SHA1.digest, pos: Position.T}
    13   type file = {src_path: Path.T, lines: string list, digest: SHA1.digest, pos: Position.T}
    14   datatype value =
    14   datatype value =
    15     Literal of Markup.T | Text of string | Typ of typ | Term of term | Fact of thm list |
    15     Literal of bool * Markup.T | Text of string | Typ of typ | Term of term | Fact of thm list |
    16     Attribute of morphism -> attribute | Files of file Exn.result list
    16     Attribute of morphism -> attribute | Files of file Exn.result list
    17   type T
    17   type T
    18   val str_of_kind: kind -> string
    18   val str_of_kind: kind -> string
    19   val pos_of: T -> Position.T
    19   val pos_of: T -> Position.T
    20   val range_of: T list -> Position.range
    20   val range_of: T list -> Position.range
    40   val is_blank: T -> bool
    40   val is_blank: T -> bool
    41   val is_newline: T -> bool
    41   val is_newline: T -> bool
    42   val inner_syntax_of: T -> string
    42   val inner_syntax_of: T -> string
    43   val source_position_of: T -> Symbol_Pos.source
    43   val source_position_of: T -> Symbol_Pos.source
    44   val content_of: T -> string
    44   val content_of: T -> string
    45   val keyword_markup: Markup.T -> string -> Markup.T
    45   val keyword_markup: bool * Markup.T -> string -> Markup.T
    46   val completion_report: T -> Position.report_text list
    46   val completion_report: T -> Position.report_text list
    47   val report: T -> Position.report_text
    47   val report: T -> Position.report_text
    48   val markup: T -> Markup.T
    48   val markup: T -> Markup.T
    49   val unparse: T -> string
    49   val unparse: T -> string
    50   val print: T -> string
    50   val print: T -> string
    85   state of internalization -- it is NOT meant to persist.*)
    85   state of internalization -- it is NOT meant to persist.*)
    86 
    86 
    87 type file = {src_path: Path.T, lines: string list, digest: SHA1.digest, pos: Position.T};
    87 type file = {src_path: Path.T, lines: string list, digest: SHA1.digest, pos: Position.T};
    88 
    88 
    89 datatype value =
    89 datatype value =
    90   Literal of Markup.T |
    90   Literal of bool * Markup.T |
    91   Text of string |
    91   Text of string |
    92   Typ of typ |
    92   Typ of typ |
    93   Term of term |
    93   Term of term |
    94   Fact of thm list |
    94   Fact of thm list |
    95   Attribute of morphism -> attribute |
    95   Attribute of morphism -> attribute |
   253   | Sync          => (Markup.control, "")
   253   | Sync          => (Markup.control, "")
   254   | EOF           => (Markup.control, "");
   254   | EOF           => (Markup.control, "");
   255 
   255 
   256 in
   256 in
   257 
   257 
   258 fun keyword_markup keyword x =
   258 fun keyword_markup (important, keyword) x =
   259   if Symbol.is_ascii_identifier x then keyword else Markup.delimiter;
   259   if important orelse Symbol.is_ascii_identifier x then keyword else Markup.delimiter;
   260 
   260 
   261 fun completion_report tok =
   261 fun completion_report tok =
   262   if is_kind Keyword tok
   262   if is_kind Keyword tok
   263   then map (fn m => ((pos_of tok, m), "")) (Completion.suppress_abbrevs (content_of tok))
   263   then map (fn m => ((pos_of tok, m), "")) (Completion.suppress_abbrevs (content_of tok))
   264   else [];
   264   else [];
   265 
   265 
   266 fun report tok =
   266 fun report tok =
   267   if is_kind Keyword tok then
   267   if is_kind Keyword tok then
   268     ((pos_of tok, keyword_markup Markup.keyword2 (content_of tok)), "")
   268     ((pos_of tok, keyword_markup (false, Markup.keyword2) (content_of tok)), "")
   269   else
   269   else
   270     let val (m, text) = token_kind_markup (kind_of tok)
   270     let val (m, text) = token_kind_markup (kind_of tok)
   271     in ((pos_of tok, m), text) end;
   271     in ((pos_of tok, m), text) end;
   272 
   272 
   273 val markup = #2 o #1 o report;
   273 val markup = #2 o #1 o report;