src/Pure/General/antiquote.ML
changeset 30613 b22d35d9ef28
parent 30590 1d9c9fcf8513
child 30635 a7d175c48228
equal deleted inserted replaced
30612:cb6421b6a18f 30613:b22d35d9ef28
    12     Open of Position.T |
    12     Open of Position.T |
    13     Close of Position.T
    13     Close of Position.T
    14   val is_antiq: 'a antiquote -> bool
    14   val is_antiq: 'a antiquote -> bool
    15   val scan: Symbol_Pos.T list -> 'a antiquote * Symbol_Pos.T list
    15   val scan: Symbol_Pos.T list -> 'a antiquote * Symbol_Pos.T list
    16   val scan_text: Symbol_Pos.T list -> Symbol_Pos.T list antiquote * Symbol_Pos.T list
    16   val scan_text: Symbol_Pos.T list -> Symbol_Pos.T list antiquote * Symbol_Pos.T list
    17   val read: (Symbol_Pos.T list -> 'a antiquote * Symbol_Pos.T list) ->
    17   val read: ('a -> unit) -> (Symbol_Pos.T list -> 'a antiquote * Symbol_Pos.T list) ->
    18     Symbol_Pos.T list * Position.T -> 'a antiquote list
    18     Symbol_Pos.T list * Position.T -> 'a antiquote list
    19 end;
    19 end;
    20 
    20 
    21 structure Antiquote: ANTIQUOTE =
    21 structure Antiquote: ANTIQUOTE =
    22 struct
    22 struct
    81 end;
    81 end;
    82 
    82 
    83 
    83 
    84 (* read *)
    84 (* read *)
    85 
    85 
    86 fun report_antiq (Antiq (_, pos)) = Position.report Markup.antiq pos
    86 fun read _ _ ([], _) = []
    87   | report_antiq _ = ();
    87   | read report scanner (syms, pos) =
    88 
       
    89 fun read _ ([], _) = []
       
    90   | read scanner (syms, pos) =
       
    91       (case Scan.read Symbol_Pos.stopper (Scan.repeat scanner) syms of
    88       (case Scan.read Symbol_Pos.stopper (Scan.repeat scanner) syms of
    92         SOME xs => (List.app report_antiq xs; check_nesting xs; xs)
    89         SOME xs =>
       
    90          (List.app (fn Antiq (_, pos) => Position.report Markup.antiq pos | Text x => report x) xs;
       
    91           check_nesting xs; xs)
    93       | NONE => error ("Malformed quotation/antiquotation source" ^ Position.str_of pos));
    92       | NONE => error ("Malformed quotation/antiquotation source" ^ Position.str_of pos));
    94 
    93 
    95 end;
    94 end;