src/Pure/Syntax/lexicon.ML
changeset 69042 6e9df530b441
parent 67556 5f86e2a9c59c
child 69320 fc221fa79741
equal deleted inserted replaced
69041:d57c460ba112 69042:6e9df530b441
    20   val scan_var: Symbol_Pos.T list scanner
    20   val scan_var: Symbol_Pos.T list scanner
    21   val scan_tvar: Symbol_Pos.T list scanner
    21   val scan_tvar: Symbol_Pos.T list scanner
    22   val is_tid: string -> bool
    22   val is_tid: string -> bool
    23   datatype token_kind =
    23   datatype token_kind =
    24     Literal | Ident | Long_Ident | Var | Type_Ident | Type_Var | Num | Float | Str |
    24     Literal | Ident | Long_Ident | Var | Type_Ident | Type_Var | Num | Float | Str |
    25     String | Cartouche | Space | Comment of Comment.kind option | Dummy | EOF
    25     String | Cartouche | Space | Comment of Comment.kind | Dummy | EOF
    26   eqtype token
    26   eqtype token
    27   val kind_of_token: token -> token_kind
    27   val kind_of_token: token -> token_kind
    28   val str_of_token: token -> string
    28   val str_of_token: token -> string
    29   val pos_of_token: token -> Position.T
    29   val pos_of_token: token -> Position.T
    30   val end_pos_of_token: token -> Position.T
    30   val end_pos_of_token: token -> Position.T
   118 
   118 
   119 (* datatype token_kind *)
   119 (* datatype token_kind *)
   120 
   120 
   121 datatype token_kind =
   121 datatype token_kind =
   122   Literal | Ident | Long_Ident | Var | Type_Ident | Type_Var | Num | Float | Str |
   122   Literal | Ident | Long_Ident | Var | Type_Ident | Type_Var | Num | Float | Str |
   123   String | Cartouche | Space | Comment of Comment.kind option | Dummy | EOF;
   123   String | Cartouche | Space | Comment of Comment.kind | Dummy | EOF;
   124 
   124 
   125 val token_kinds =
   125 val token_kinds =
   126   Vector.fromList
   126   Vector.fromList
   127    [Literal, Ident, Long_Ident, Var, Type_Ident, Type_Var, Num, Float, Str,
   127    [Literal, Ident, Long_Ident, Var, Type_Ident, Type_Var, Num, Float, Str,
   128     String, Cartouche, Space, Comment NONE, Comment (SOME Comment.Comment),
   128     String, Cartouche, Space, Comment Comment.Comment, Comment Comment.Cancel,
   129     Comment (SOME Comment.Cancel), Comment (SOME Comment.Latex), Dummy, EOF];
   129     Comment Comment.Latex, Dummy, EOF];
   130 
   130 
   131 fun token_kind i = Vector.sub (token_kinds, i);
   131 fun token_kind i = Vector.sub (token_kinds, i);
   132 fun token_kind_index k = #1 (the (Vector.findi (fn (_, k') => k = k') token_kinds));
   132 fun token_kind_index k = #1 (the (Vector.findi (fn (_, k') => k = k') token_kinds));
   133 
   133 
   134 
   134 
   299 
   299 
   300     val scan_lit = Scan.literal lex >> token Literal;
   300     val scan_lit = Scan.literal lex >> token Literal;
   301 
   301 
   302     val scan =
   302     val scan =
   303       Symbol_Pos.scan_cartouche err_prefix >> token Cartouche ||
   303       Symbol_Pos.scan_cartouche err_prefix >> token Cartouche ||
   304       Symbol_Pos.scan_comment err_prefix >> token (Comment NONE) ||
   304       Comment.scan >> (fn (kind, ss) => token (Comment kind) ss) ||
   305       Comment.scan >> (fn (kind, ss) => token (Comment (SOME kind)) ss) ||
       
   306       Scan.max token_leq scan_lit scan_val ||
   305       Scan.max token_leq scan_lit scan_val ||
   307       scan_string >> token String ||
   306       scan_string >> token String ||
   308       scan_str >> token Str ||
   307       scan_str >> token Str ||
   309       Scan.many1 (Symbol.is_blank o Symbol_Pos.symbol) >> token Space;
   308       Scan.many1 (Symbol.is_blank o Symbol_Pos.symbol) >> token Space;
   310   in
   309   in