src/Pure/Isar/token.ML
changeset 40958 755f8fe7ced9
parent 40627 becf5d5187cc
child 42290 b1f544c84040
equal deleted inserted replaced
40957:f840361f8e69 40958:755f8fe7ced9
     7 signature TOKEN =
     7 signature TOKEN =
     8 sig
     8 sig
     9   datatype kind =
     9   datatype kind =
    10     Command | Keyword | Ident | LongIdent | SymIdent | Var | TypeIdent | TypeVar |
    10     Command | Keyword | Ident | LongIdent | SymIdent | Var | TypeIdent | TypeVar |
    11     Nat | Float | String | AltString | Verbatim | Space | Comment | InternalValue |
    11     Nat | Float | String | AltString | Verbatim | Space | Comment | InternalValue |
    12     Malformed | Error of string | Sync | EOF
    12     Error of string | Sync | EOF
    13   datatype value =
    13   datatype value =
    14     Text of string | Typ of typ | Term of term | Fact of thm list |
    14     Text of string | Typ of typ | Term of term | Fact of thm list |
    15     Attribute of morphism -> attribute
    15     Attribute of morphism -> attribute
    16   type T
    16   type T
    17   val str_of_kind: kind -> string
    17   val str_of_kind: kind -> string
    88 (* datatype token *)
    88 (* datatype token *)
    89 
    89 
    90 datatype kind =
    90 datatype kind =
    91   Command | Keyword | Ident | LongIdent | SymIdent | Var | TypeIdent | TypeVar |
    91   Command | Keyword | Ident | LongIdent | SymIdent | Var | TypeIdent | TypeVar |
    92   Nat | Float | String | AltString | Verbatim | Space | Comment | InternalValue |
    92   Nat | Float | String | AltString | Verbatim | Space | Comment | InternalValue |
    93   Malformed | Error of string | Sync | EOF;
    93   Error of string | Sync | EOF;
    94 
    94 
    95 datatype T = Token of (Symbol_Pos.text * Position.range) * (kind * string) * slot;
    95 datatype T = Token of (Symbol_Pos.text * Position.range) * (kind * string) * slot;
    96 
    96 
    97 val str_of_kind =
    97 val str_of_kind =
    98  fn Command => "command"
    98  fn Command => "command"
   109   | AltString => "back-quoted string"
   109   | AltString => "back-quoted string"
   110   | Verbatim => "verbatim text"
   110   | Verbatim => "verbatim text"
   111   | Space => "white space"
   111   | Space => "white space"
   112   | Comment => "comment text"
   112   | Comment => "comment text"
   113   | InternalValue => "internal value"
   113   | InternalValue => "internal value"
   114   | Malformed => "malformed symbolic character"
       
   115   | Error _ => "bad input"
   114   | Error _ => "bad input"
   116   | Sync => "sync marker"
   115   | Sync => "sync marker"
   117   | EOF => "end-of-file";
   116   | EOF => "end-of-file";
   118 
   117 
   119 
   118 
   329   (Symbol_Pos.scan_string >> token_range String ||
   328   (Symbol_Pos.scan_string >> token_range String ||
   330     Symbol_Pos.scan_alt_string >> token_range AltString ||
   329     Symbol_Pos.scan_alt_string >> token_range AltString ||
   331     scan_verbatim >> token_range Verbatim ||
   330     scan_verbatim >> token_range Verbatim ||
   332     scan_comment >> token_range Comment ||
   331     scan_comment >> token_range Comment ||
   333     scan_space >> token Space ||
   332     scan_space >> token Space ||
   334     Scan.one (Symbol.is_malformed o Symbol_Pos.symbol) >> (token Malformed o single) ||
       
   335     Scan.one (Symbol.is_sync o Symbol_Pos.symbol) >> (token Sync o single) ||
   333     Scan.one (Symbol.is_sync o Symbol_Pos.symbol) >> (token Sync o single) ||
   336     (Scan.max token_leq
   334     (Scan.max token_leq
   337       (Scan.max token_leq
   335       (Scan.max token_leq
   338         (Scan.literal lex2 >> pair Command)
   336         (Scan.literal lex2 >> pair Command)
   339         (Scan.literal lex1 >> pair Keyword))
   337         (Scan.literal lex1 >> pair Keyword))