src/Pure/General/antiquote.ML
changeset 48768 abc45de5bb22
parent 48764 4fe0920d5049
child 48992 0518bf89c777
equal deleted inserted replaced
48767:7f0c469cc796 48768:abc45de5bb22
    10     Text of 'a |
    10     Text of 'a |
    11     Antiq of Symbol_Pos.T list * Position.range |
    11     Antiq of Symbol_Pos.T list * Position.range |
    12     Open of Position.T |
    12     Open of Position.T |
    13     Close of Position.T
    13     Close of Position.T
    14   val is_text: 'a antiquote -> bool
    14   val is_text: 'a antiquote -> bool
    15   val reports_of: ('a -> Position.report list) -> 'a antiquote list -> Position.report list
    15   val reports_of: ('a -> Position.report_text list) ->
       
    16     'a antiquote list -> Position.report_text list
    16   val check_nesting: 'a antiquote list -> unit
    17   val check_nesting: 'a antiquote list -> unit
    17   val scan_antiq: Symbol_Pos.T list -> (Symbol_Pos.T list * Position.range) * Symbol_Pos.T list
    18   val scan_antiq: Symbol_Pos.T list -> (Symbol_Pos.T list * Position.range) * Symbol_Pos.T list
    18   val scan: Symbol_Pos.T list -> 'a antiquote * Symbol_Pos.T list
    19   val scan: Symbol_Pos.T list -> 'a antiquote * Symbol_Pos.T list
    19   val scan_text: Symbol_Pos.T list -> Symbol_Pos.T list antiquote * Symbol_Pos.T list
    20   val scan_text: Symbol_Pos.T list -> Symbol_Pos.T list antiquote * Symbol_Pos.T list
    20   val read: Symbol_Pos.T list * Position.T -> Symbol_Pos.T list antiquote list
    21   val read: Symbol_Pos.T list * Position.T -> Symbol_Pos.T list antiquote list
    38 (* reports *)
    39 (* reports *)
    39 
    40 
    40 fun reports_of text =
    41 fun reports_of text =
    41   maps
    42   maps
    42     (fn Text x => text x
    43     (fn Text x => text x
    43       | Antiq (_, (pos, _)) => [(pos, Isabelle_Markup.antiq)]
    44       | Antiq (_, (pos, _)) => [((pos, Isabelle_Markup.antiq), "")]
    44       | Open pos => [(pos, Isabelle_Markup.antiq)]
    45       | Open pos => [((pos, Isabelle_Markup.antiq), "")]
    45       | Close pos => [(pos, Isabelle_Markup.antiq)]);
    46       | Close pos => [((pos, Isabelle_Markup.antiq), "")]);
    46 
    47 
    47 
    48 
    48 (* check_nesting *)
    49 (* check_nesting *)
    49 
    50 
    50 fun err_unbalanced pos =
    51 fun err_unbalanced pos =
    97 
    98 
    98 (* read *)
    99 (* read *)
    99 
   100 
   100 fun read (syms, pos) =
   101 fun read (syms, pos) =
   101   (case Scan.read Symbol_Pos.stopper (Scan.repeat scan_text) syms of
   102   (case Scan.read Symbol_Pos.stopper (Scan.repeat scan_text) syms of
   102     SOME xs => (Position.reports (reports_of (K []) xs); check_nesting xs; xs)
   103     SOME xs => (Position.reports_text (reports_of (K []) xs); check_nesting xs; xs)
   103   | NONE => error ("Malformed quotation/antiquotation source" ^ Position.str_of pos));
   104   | NONE => error ("Malformed quotation/antiquotation source" ^ Position.str_of pos));
   104 
   105 
   105 end;
   106 end;