Support for quoted strings within comments.

git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13469 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2013-03-29 15:36:24 +00:00
parent 1a63c4659c
commit f510f9b4a1
1 changed files with 22 additions and 0 deletions

View File

@ -473,6 +473,28 @@ and comment = parse
is_in_string := false;
store_string_char '"';
comment lexbuf }
| "{" lowercase* "|"
{
let delim = Lexing.lexeme lexbuf in
let delim = String.sub delim 1 (String.length delim - 2) in
string_start_loc := Location.curr lexbuf;
store_lexeme lexbuf;
is_in_string := true;
begin try quoted_string delim lexbuf
with Error (Unterminated_string, _) ->
match !comment_start_loc with
| [] -> assert false
| loc :: _ ->
let start = List.hd (List.rev !comment_start_loc) in
comment_start_loc := [];
raise (Error (Unterminated_string_in_comment start, loc))
end;
is_in_string := false;
store_string_char '|';
store_string delim;
store_string_char '}';
comment lexbuf }
| "''"
{ store_lexeme lexbuf; comment lexbuf }
| "'" newline "'"