Commit 64b01477 authored by Kim Nguyễn's avatar Kim Nguyễn

Change the behaviour introduced by commit:bcf40231

[ 'abc'ab ] is now parsed as [ 'abc' ab ] to maintain backward compatibility.
Change the warning message accordingly.
parent b862df33
......@@ -294,8 +294,10 @@ let rec token = lexer
| ["?+*"] "?" | "#" ->
return lexbuf (KEYWORD (L.utf8_lexeme lexbuf))
(* the three followning rules work together and are replicated in the
comment lexer *)
(*
BEGIN lexing of single quoted string/polymorphic variables
these rules should also be mimicked in the comment lexer.
*)
| "'" ([^ '\t' '\n' '\r' '\''] | '\\' '\'')* "'" (not_ncname_letter | eof) ->
(* two single quotes not followed by an xml_letter must be a string
......@@ -305,11 +307,12 @@ let rec token = lexer
do_string lexbuf
| "'" ncname "'" ncname ->
(* Tokenize [ 'abc'abc ] as [ 'abc' abc ], to ensure backward compatibility with 0.x CDuce *)
let s = L.utf8_lexeme lexbuf in
warning lexbuf
(Printf.sprintf "ambiguous sequence of polymorphic variables (%s). Add a space before the second quote." s);
(Printf.sprintf "string literal followed by an identifier (%s) is ambiguous. Add a space after the second quote." s);
L.rollback lexbuf;
do_variable lexbuf
do_string lexbuf
| "'" ncname ->
(* then try to read it as variable *)
......@@ -321,6 +324,9 @@ let rec token = lexer
character as a string to get a decent error message *)
L.rollback lexbuf;
do_string lexbuf
(*
END lexing of single quoted string/polymorphic variables
*)
| "(*" ->
in_comment := true;
......@@ -359,13 +365,13 @@ and comment start = lexer
| "*)" ->
()
| "'" ([^ '\t' '\n' '\r' '\''] | '\\' '\'')* "'" (not_ncname_letter | eof) ->
| ("'" ([^ '\t' '\n' '\r' '\''] | '\\' '\'')* "'" (not_ncname_letter | eof))
| ("'" ncname "'" ncname) ->
(* merge these two cases, and don't emit a warning since we are in a comment *)
L.rollback lexbuf;
ignore (do_string lexbuf);
comment start lexbuf
| "'" ncname -> comment start lexbuf
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment