Disallow .~ in extended indexing operators. (#2106)
Disallow .~ in the lexer to preserve MetaOCaml compatibility.master
parent
ef76e6e630
commit
20f4c6ced3
5
Changes
5
Changes
|
@ -15,6 +15,11 @@ Working version
|
||||||
- GPR#1892: Allow shadowing of items coming from an include
|
- GPR#1892: Allow shadowing of items coming from an include
|
||||||
(Thomas Refis, review by Gabriel Radanne)
|
(Thomas Refis, review by Gabriel Radanne)
|
||||||
|
|
||||||
|
* GPR#2106: .~ is now a reserved keyword, and is no longer available
|
||||||
|
for use in extended indexing operators
|
||||||
|
(Jeremy Yallop, review by Gabriel Scherer, Florian Angeletti, and
|
||||||
|
Damien Doligez)
|
||||||
|
|
||||||
### Type system:
|
### Type system:
|
||||||
|
|
||||||
- GPR#1826: allow expanding a type to a private abbreviation instead of
|
- GPR#1826: allow expanding a type to a private abbreviation instead of
|
||||||
|
|
|
@ -280,9 +280,9 @@ The following character sequences are also keywords:
|
||||||
%
|
%
|
||||||
\begin{alltt}
|
\begin{alltt}
|
||||||
" != # & && ' ( ) * + , -"
|
" != # & && ' ( ) * + , -"
|
||||||
" -. -> . .. : :: := :> ; ;; <"
|
" -. -> . .. .~ : :: := :> ; ;;"
|
||||||
" <- = > >] >} ? [ [< [> [| ]"
|
" < <- = > >] >} ? [ [< [> [|"
|
||||||
" _ ` { {< | |] || } ~"
|
" ] _ ` { {< | |] || } ~"
|
||||||
\end{alltt}
|
\end{alltt}
|
||||||
%
|
%
|
||||||
Note that the following identifiers are keywords of the Camlp4
|
Note that the following identifiers are keywords of the Camlp4
|
||||||
|
|
|
@ -27,6 +27,7 @@ val skip_hash_bang: Lexing.lexbuf -> unit
|
||||||
type error =
|
type error =
|
||||||
| Illegal_character of char
|
| Illegal_character of char
|
||||||
| Illegal_escape of string * string option
|
| Illegal_escape of string * string option
|
||||||
|
| Reserved_sequence of string * string option
|
||||||
| Unterminated_comment of Location.t
|
| Unterminated_comment of Location.t
|
||||||
| Unterminated_string
|
| Unterminated_string
|
||||||
| Unterminated_string_in_comment of Location.t * Location.t
|
| Unterminated_string_in_comment of Location.t * Location.t
|
||||||
|
|
|
@ -23,6 +23,7 @@ open Parser
|
||||||
type error =
|
type error =
|
||||||
| Illegal_character of char
|
| Illegal_character of char
|
||||||
| Illegal_escape of string * string option
|
| Illegal_escape of string * string option
|
||||||
|
| Reserved_sequence of string * string option
|
||||||
| Unterminated_comment of Location.t
|
| Unterminated_comment of Location.t
|
||||||
| Unterminated_string
|
| Unterminated_string
|
||||||
| Unterminated_string_in_comment of Location.t * Location.t
|
| Unterminated_string_in_comment of Location.t * Location.t
|
||||||
|
@ -263,6 +264,12 @@ let prepare_error loc = function
|
||||||
(fun ppf -> match explanation with
|
(fun ppf -> match explanation with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
| Some expl -> fprintf ppf ": %s" expl)
|
| Some expl -> fprintf ppf ": %s" expl)
|
||||||
|
| Reserved_sequence (s, explanation) ->
|
||||||
|
Location.errorf ~loc
|
||||||
|
"Reserved character sequence: %s%t" s
|
||||||
|
(fun ppf -> match explanation with
|
||||||
|
| None -> ()
|
||||||
|
| Some expl -> fprintf ppf " %s" expl)
|
||||||
| Unterminated_comment _ ->
|
| Unterminated_comment _ ->
|
||||||
Location.errorf ~loc "Comment not terminated"
|
Location.errorf ~loc "Comment not terminated"
|
||||||
| Unterminated_string ->
|
| Unterminated_string ->
|
||||||
|
@ -305,7 +312,7 @@ let identchar_latin1 =
|
||||||
let symbolchar =
|
let symbolchar =
|
||||||
['!' '$' '%' '&' '*' '+' '-' '.' '/' ':' '<' '=' '>' '?' '@' '^' '|' '~']
|
['!' '$' '%' '&' '*' '+' '-' '.' '/' ':' '<' '=' '>' '?' '@' '^' '|' '~']
|
||||||
let dotsymbolchar =
|
let dotsymbolchar =
|
||||||
['!' '$' '%' '&' '*' '+' '-' '/' ':' '=' '>' '?' '@' '^' '|' '~']
|
['!' '$' '%' '&' '*' '+' '-' '/' ':' '=' '>' '?' '@' '^' '|']
|
||||||
let decimal_literal =
|
let decimal_literal =
|
||||||
['0'-'9'] ['0'-'9' '_']*
|
['0'-'9'] ['0'-'9' '_']*
|
||||||
let hex_digit =
|
let hex_digit =
|
||||||
|
@ -343,6 +350,9 @@ rule token = parse
|
||||||
{ UNDERSCORE }
|
{ UNDERSCORE }
|
||||||
| "~"
|
| "~"
|
||||||
{ TILDE }
|
{ TILDE }
|
||||||
|
| ".~"
|
||||||
|
{ error lexbuf
|
||||||
|
(Reserved_sequence (".~", Some "is reserved for use in MetaOCaml")) }
|
||||||
| "~" (lowercase identchar * as name) ':'
|
| "~" (lowercase identchar * as name) ':'
|
||||||
{ check_label_name lexbuf name;
|
{ check_label_name lexbuf name;
|
||||||
LABEL name }
|
LABEL name }
|
||||||
|
|
|
@ -30,6 +30,7 @@ let rec skip_phrase lexbuf =
|
||||||
| _ -> skip_phrase lexbuf
|
| _ -> skip_phrase lexbuf
|
||||||
| exception (Lexer.Error (Lexer.Unterminated_comment _, _)
|
| exception (Lexer.Error (Lexer.Unterminated_comment _, _)
|
||||||
| Lexer.Error (Lexer.Unterminated_string, _)
|
| Lexer.Error (Lexer.Unterminated_string, _)
|
||||||
|
| Lexer.Error (Lexer.Reserved_sequence _, _)
|
||||||
| Lexer.Error (Lexer.Unterminated_string_in_comment _, _)
|
| Lexer.Error (Lexer.Unterminated_string_in_comment _, _)
|
||||||
| Lexer.Error (Lexer.Illegal_character _, _)) ->
|
| Lexer.Error (Lexer.Illegal_character _, _)) ->
|
||||||
skip_phrase lexbuf
|
skip_phrase lexbuf
|
||||||
|
|
Loading…
Reference in New Issue