src/Pure/Isar/token.ML
changeset 67502 1be337a7584f
parent 67501 182a18af5b41
child 67503 7bb069073414
equal deleted inserted replaced
67501:182a18af5b41 67502:1be337a7584f
    91   val make_string: string * Position.T -> T
    91   val make_string: string * Position.T -> T
    92   val make_int: int -> T list
    92   val make_int: int -> T list
    93   val make_src: string * Position.T -> T list -> src
    93   val make_src: string * Position.T -> T list -> src
    94   type 'a parser = T list -> 'a * T list
    94   type 'a parser = T list -> 'a * T list
    95   type 'a context_parser = Context.generic * T list -> 'a * (Context.generic * T list)
    95   type 'a context_parser = Context.generic * T list -> 'a * (Context.generic * T list)
    96   val read_no_commands: Keyword.keywords -> 'a parser -> Symbol_Pos.T list -> 'a list
    96   val read_body: Keyword.keywords -> 'a parser -> Symbol_Pos.T list -> 'a list
    97   val read_antiq: Keyword.keywords -> 'a parser -> Symbol_Pos.T list * Position.T -> 'a
    97   val read_antiq: Keyword.keywords -> 'a parser -> Symbol_Pos.T list * Position.T -> 'a
    98   val syntax_generic: 'a context_parser -> src -> Context.generic -> 'a * Context.generic
    98   val syntax_generic: 'a context_parser -> src -> Context.generic -> 'a * Context.generic
    99   val syntax: 'a context_parser -> src -> Proof.context -> 'a * Proof.context
    99   val syntax: 'a context_parser -> src -> Proof.context -> 'a * Proof.context
   100 end;
   100 end;
   101 
   101 
   705 
   705 
   706 type 'a parser = T list -> 'a * T list;
   706 type 'a parser = T list -> 'a * T list;
   707 type 'a context_parser = Context.generic * T list -> 'a * (Context.generic * T list);
   707 type 'a context_parser = Context.generic * T list -> 'a * (Context.generic * T list);
   708 
   708 
   709 
   709 
   710 (* read antiquotation source *)
   710 (* read body -- e.g. antiquotation source *)
   711 
   711 
   712 fun read_no_commands keywords scan syms =
   712 fun read_body keywords scan =
   713   Source.of_list syms
   713   tokenize (Keyword.no_command_keywords keywords) {strict = true}
   714   |> make_source (Keyword.no_command_keywords keywords) {strict = true}
   714   #> filter is_proper
   715   |> Source.filter is_proper
   715   #> Source.of_list
   716   |> Source.source stopper (Scan.error (Scan.bulk scan))
   716   #> Source.source stopper (Scan.error (Scan.bulk scan))
   717   |> Source.exhaust;
   717   #> Source.exhaust;
   718 
   718 
   719 fun read_antiq keywords scan (syms, pos) =
   719 fun read_antiq keywords scan (syms, pos) =
   720   let
   720   (case read_body keywords scan syms of
   721     fun err msg =
   721     [x] => x
   722       cat_error msg ("Malformed antiquotation" ^ Position.here pos ^ ":\n" ^
   722   | _ =>
   723         "@{" ^ Symbol_Pos.content syms ^ "}");
   723       error ("Malformed antiquotation" ^ Position.here pos ^ ":\n" ^
   724     val res = read_no_commands keywords scan syms handle ERROR msg => err msg;
   724         "@{" ^ Symbol_Pos.content syms ^ "}"));
   725   in (case res of [x] => x | _ => err "") end;
       
   726 
   725 
   727 
   726 
   728 (* wrapped syntax *)
   727 (* wrapped syntax *)
   729 
   728 
   730 fun syntax_generic scan src context =
   729 fun syntax_generic scan src context =