src/Pure/Syntax/source.ML
changeset 4983 2c567fcdb36d
parent 4976 19f48dafe5d3
child 5019 b6363fa0564f
equal deleted inserted replaced
4982:6f96354267e0 4983:2c567fcdb36d
     9 sig
     9 sig
    10   type ('a, 'b) source
    10   type ('a, 'b) source
    11   val set_prompt: string -> ('a, 'b) source -> ('a, 'b) source
    11   val set_prompt: string -> ('a, 'b) source -> ('a, 'b) source
    12   val get: ('a, 'b) source -> 'a list * ('a, 'b) source
    12   val get: ('a, 'b) source -> 'a list * ('a, 'b) source
    13   val unget: 'a list * ('a, 'b) source -> ('a, 'b) source
    13   val unget: 'a list * ('a, 'b) source -> ('a, 'b) source
    14   val get_single: ('a, 'b) source -> 'a option * ('a, 'b) source
    14   val get_single: ('a, 'b) source -> ('a * ('a, 'b) source) option
    15   val exhaust: ('a, 'b) source -> 'a list
    15   val exhaust: ('a, 'b) source -> 'a list
    16   val mapfilter: ('a -> 'b option) -> ('a, 'c) source -> ('b, ('a, 'c) source) source
    16   val mapfilter: ('a -> 'b option) -> ('a, 'c) source -> ('b, ('a, 'c) source) source
    17   val filter: ('a -> bool) -> ('a, 'b) source -> ('a, ('a, 'b) source) source
    17   val filter: ('a -> bool) -> ('a, 'b) source -> ('a, ('a, 'b) source) source
    18   val of_list: 'a list -> ('a, 'a list) source
    18   val of_list: 'a list -> ('a, 'a list) source
    19   val of_string: string -> (string, string list) source
    19   val of_string: string -> (string, string list) source
    68 
    68 
    69 fun get_prompt prompt src = get (set_prompt prompt src);
    69 fun get_prompt prompt src = get (set_prompt prompt src);
    70 
    70 
    71 fun get_single src =
    71 fun get_single src =
    72   (case get src of
    72   (case get src of
    73     ([], src') => (None, src')
    73     ([], _) => None
    74   | (x :: xs, src') => (Some x, unget (xs, src')));
    74   | (x :: xs, src') => Some (x, unget (xs, src')));
    75 
    75 
    76 fun exhaust src =
    76 fun exhaust src =
    77   (case get src of
    77   (case get src of
    78     ([], _) => []
    78     ([], _) => []
    79   | (xs, src') => xs @ exhaust src');
    79   | (xs, src') => xs @ exhaust src');