src/Pure/Syntax/lexicon.ML
changeset 2363 963285471dc5
parent 1507 f600215b6ea7
child 2583 690835a06cf2
equal deleted inserted replaced
2362:4744b27cdf89 2363:963285471dc5
    75   val display_token: token -> string
    75   val display_token: token -> string
    76   val matching_tokens: token * token -> bool
    76   val matching_tokens: token * token -> bool
    77   val token_assoc: (token option * 'a list) list * token -> 'a list
    77   val token_assoc: (token option * 'a list) list * token -> 'a list
    78   val valued_token: token -> bool
    78   val valued_token: token -> bool
    79   val predef_term: string -> token option
    79   val predef_term: string -> token option
    80   val tokenize: lexicon -> bool -> string -> token list
    80   val tokenize: lexicon -> bool -> string list -> token list
    81   end;
    81   end;
    82 
    82 
    83 structure Lexicon : LEXICON =
    83 structure Lexicon : LEXICON =
    84 struct
    84 struct
    85 
    85 
   370 
   370 
   371 
   371 
   372 
   372 
   373 (** tokenize **)
   373 (** tokenize **)
   374 
   374 
   375 fun tokenize lex xids str =
   375 fun tokenize lex xids chs =
   376   let
   376   let
   377     val scan_xid =
   377     val scan_xid =
   378       if xids then $$ "_" ^^ scan_id || scan_id
   378       if xids then $$ "_" ^^ scan_id || scan_id
   379       else scan_id;
   379       else scan_id;
   380 
   380 
   407           else
   407           else
   408             (case max_of scan_lit scan_val chs of
   408             (case max_of scan_lit scan_val chs of
   409               (None, _) => error ("Lexical error at: " ^ quote (implode chs))
   409               (None, _) => error ("Lexical error at: " ^ quote (implode chs))
   410             | (Some (tk, s), chs') => scan (tk s :: rev_toks, chs'));
   410             | (Some (tk, s), chs') => scan (tk s :: rev_toks, chs'));
   411   in
   411   in
   412     scan ([], explode str)
   412     scan ([], chs)
   413   end;
   413   end;
   414 
   414 
   415 
   415 
   416 
   416 
   417 (** scan variables **)
   417 (** scan variables **)