src/Pure/General/antiquote.ML
changeset 30683 e8ac1f9d9469
parent 30641 72980f8d7ee8
child 39507 839873937ddd
equal deleted inserted replaced
30682:dcb233670c98 30683:e8ac1f9d9469
     6 
     6 
     7 signature ANTIQUOTE =
     7 signature ANTIQUOTE =
     8 sig
     8 sig
     9   datatype 'a antiquote =
     9   datatype 'a antiquote =
    10     Text of 'a |
    10     Text of 'a |
    11     Antiq of Symbol_Pos.T list * Position.T |
    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 report: ('a -> unit) -> 'a antiquote -> unit
    15   val report: ('a -> unit) -> 'a antiquote -> unit
    16   val check_nesting: 'a antiquote list -> unit
    16   val check_nesting: 'a antiquote list -> unit
    24 
    24 
    25 (* datatype antiquote *)
    25 (* datatype antiquote *)
    26 
    26 
    27 datatype 'a antiquote =
    27 datatype 'a antiquote =
    28   Text of 'a |
    28   Text of 'a |
    29   Antiq of Symbol_Pos.T list * Position.T |
    29   Antiq of Symbol_Pos.T list * Position.range |
    30   Open of Position.T |
    30   Open of Position.T |
    31   Close of Position.T;
    31   Close of Position.T;
    32 
    32 
    33 fun is_text (Text _) = true
    33 fun is_text (Text _) = true
    34   | is_text _ = false;
    34   | is_text _ = false;
    37 (* report *)
    37 (* report *)
    38 
    38 
    39 val report_antiq = Position.report Markup.antiq;
    39 val report_antiq = Position.report Markup.antiq;
    40 
    40 
    41 fun report report_text (Text x) = report_text x
    41 fun report report_text (Text x) = report_text x
    42   | report _ (Antiq (_, pos)) = report_antiq pos
    42   | report _ (Antiq (_, (pos, _))) = report_antiq pos
    43   | report _ (Open pos) = report_antiq pos
    43   | report _ (Open pos) = report_antiq pos
    44   | report _ (Close pos) = report_antiq pos;
    44   | report _ (Close pos) = report_antiq pos;
    45 
    45 
    46 
    46 
    47 (* check_nesting *)
    47 (* check_nesting *)
    77 
    77 
    78 val scan_antiq =
    78 val scan_antiq =
    79   Symbol_Pos.scan_pos -- ($$$ "@" |-- $$$ "{" |--
    79   Symbol_Pos.scan_pos -- ($$$ "@" |-- $$$ "{" |--
    80     Symbol_Pos.!!! "missing closing brace of antiquotation"
    80     Symbol_Pos.!!! "missing closing brace of antiquotation"
    81       (Scan.repeat scan_ant -- ($$$ "}" |-- Symbol_Pos.scan_pos)))
    81       (Scan.repeat scan_ant -- ($$$ "}" |-- Symbol_Pos.scan_pos)))
    82   >> (fn (pos1, (body, pos2)) => (flat body, Position.encode_range (pos1, pos2)));
    82   >> (fn (pos1, (body, pos2)) => (flat body, Position.range pos1 pos2));
    83 
    83 
    84 val scan_open = Symbol_Pos.scan_pos --| $$$ "\\<lbrace>";
    84 val scan_open = Symbol_Pos.scan_pos --| $$$ "\\<lbrace>";
    85 val scan_close = Symbol_Pos.scan_pos --| $$$ "\\<rbrace>";
    85 val scan_close = Symbol_Pos.scan_pos --| $$$ "\\<rbrace>";
    86 
    86 
    87 in
    87 in