src/Pure/Isar/antiquote.ML
changeset 19305 5c16895d548b
parent 14981 e73f8140af78
child 22114 560c5b5dda1c
equal deleted inserted replaced
19304:15f001295a7b 19305:5c16895d548b
    34 
    34 
    35 structure T = OuterLex;
    35 structure T = OuterLex;
    36 
    36 
    37 val scan_txt =
    37 val scan_txt =
    38   T.scan_blank ||
    38   T.scan_blank ||
    39   T.keep_line ($$ "@" --| Scan.ahead (Scan.one (not_equal "{"))) ||
    39   T.keep_line ($$ "@" --| Scan.ahead (~$$ "{")) ||
    40   T.keep_line (Scan.one (not_equal "@" andf Symbol.not_sync andf Symbol.not_eof));
    40   T.keep_line (Scan.one (fn s => s <> "@" andalso Symbol.not_sync s andalso Symbol.not_eof s));
    41 
    41 
    42 fun escape "\\" = "\\\\"
    42 fun escape "\\" = "\\\\"
    43   | escape "\"" = "\\\""
    43   | escape "\"" = "\\\""
    44   | escape s = s;
    44   | escape s = s;
    45 
    45 
    46 val quote_escape = Library.quote o implode o map escape o Symbol.explode;
    46 val quote_escape = Library.quote o implode o map escape o Symbol.explode;
    47 
    47 
    48 val scan_ant =
    48 val scan_ant =
    49   T.scan_blank ||
    49   T.scan_blank ||
    50   T.scan_string >> quote_escape ||
    50   T.scan_string >> quote_escape ||
    51   T.keep_line (Scan.one (not_equal "}" andf Symbol.not_sync andf Symbol.not_eof));
    51   T.keep_line (Scan.one (fn s => s <> "}" andalso Symbol.not_sync s andalso Symbol.not_eof s));
    52 
    52 
    53 val scan_antiq =
    53 val scan_antiq =
    54   T.keep_line ($$ "@" -- $$ "{") |--
    54   T.keep_line ($$ "@" -- $$ "{") |--
    55     T.!!! "missing closing brace of antiquotation"
    55     T.!!! "missing closing brace of antiquotation"
    56       (Scan.repeat scan_ant >> implode) --| T.keep_line ($$ "}");
    56       (Scan.repeat scan_ant >> implode) --| T.keep_line ($$ "}");