File tree Expand file tree Collapse file tree 6 files changed +25
-8
lines changed Expand file tree Collapse file tree 6 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 33open Lplib
44open Base
55
6+ (* * Exception raised by the parser when an unqualified identifier is given
7+ instead of a qualified one. *)
8+ exception NotQualified
9+
610(* * [err_fmt] warning/error output formatter. *)
711let err_fmt = Stdlib. ref Format. err_formatter
812
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ let fail : Sedlexing.lexbuf -> string -> 'a = fun lb msg ->
2121 raise (SyntaxError (make_pos (lexing_positions lb) msg))
2222
2323let invalid_character : Sedlexing.lexbuf -> 'a = fun lb ->
24- fail lb ( " Invalid character: \" " ^ Utf8. lexeme lb ^ " \" . " )
24+ fail lb " Invalid character"
2525
2626(* * Tokens. *)
2727type token =
Original file line number Diff line number Diff line change 141141 | s= UID { make_pos $ sloc ([] , s) }
142142 | p= QID { qid_of_path $ sloc p }
143143
144- path: p= QID { make_pos $ sloc (List. rev p) }
144+ path:
145+ | UID { raise Error. NotQualified }
146+ | p= QID { make_pos $ sloc (List. rev p) }
145147
146148qid_expl:
147149 | s= UID_EXPL { make_pos $ sloc ([] , s) }
@@ -279,8 +281,8 @@ command:
279281 { make_pos $ sloc (P_require (true ,l)) }
280282 | REQUIRE l= list (path) SEMICOLON
281283 { make_pos $ sloc (P_require (false ,l)) }
282- | REQUIRE i = path AS a = uid SEMICOLON
283- { make_pos $ sloc (P_require_as (i,a )) }
284+ | REQUIRE p = path AS i = uid SEMICOLON
285+ { make_pos $ sloc (P_require_as (p,i )) }
284286 | OPEN l= list (path) SEMICOLON
285287 { make_pos $ sloc (P_open l) }
286288 | ms= modifier* SYMBOL s= uid al= param_list* COLON a= term
Original file line number Diff line number Diff line change @@ -60,9 +60,14 @@ module Lp : PARSER = struct
6060 | End_of_file -> Option. iter close_in inchan; None
6161 | LpLexer. SyntaxError {pos =None ; _} -> assert false
6262 | LpLexer. SyntaxError {pos =Some pos ; elt} -> parser_fatal pos " %s" elt
63+ | Error. NotQualified ->
64+ let pos = Pos. locate (Sedlexing. lexing_positions lb) in
65+ parser_fatal pos
66+ " Unqualified identifier (the root_path is missing)."
6367 | LpParser. Error ->
6468 let pos = Pos. locate (Sedlexing. lexing_positions lb) in
65- parser_fatal pos " Unexpected token: %s" (Sedlexing.Utf8. lexeme lb)
69+ parser_fatal pos " Unexpected token: \" %s\" ."
70+ (Sedlexing.Utf8. lexeme lb)
6671 in
6772 Stream. from generator
6873
@@ -105,7 +110,7 @@ module Dk : PARSER = struct
105110 | End_of_file -> Option. iter close_in inchan; None
106111 | DkParser. Error ->
107112 let pos = Pos. locate (Lexing. (lb.lex_start_p, lb.lex_curr_p)) in
108- parser_fatal pos " Unexpected token [%s] ." (Lexing. lexeme lb)
113+ parser_fatal pos " Unexpected token \" %s \" ." (Lexing. lexeme lb)
109114 in
110115 Stream. from generator
111116
Original file line number Diff line number Diff line change @@ -200,7 +200,12 @@ and scope_parsed : int -> mode -> sig_state -> env -> p_term -> tbox =
200200 begin
201201 match p_head.elt, md with
202202 | P_Patt _ , M_LHS _ when args <> [] ->
203- fatal t.pos " Pattern variables cannot be applied."
203+ begin match args with
204+ | [{elt= P_Expl _;_}] ->
205+ fatal t.pos " Explicit terms are forbidden in rule LHS. \
206+ You perhaps forgot to write a dot before?"
207+ | _ -> fatal t.pos " Pattern variables cannot be applied."
208+ end
204209 | _ -> ()
205210 end ;
206211 (* Scope the head and obtain the implicitness of arguments. *)
@@ -305,7 +310,7 @@ and scope_binder : ?warn:bool -> int -> mode -> sig_state ->
305310 cons a (Bindlib. bind_var v t)
306311 | Some {elt =id ;pos} ::idopts ->
307312 if is_invalid_bindlib_id id then
308- fatal pos " %s : Escaped identifiers or regular identifiers \
313+ fatal pos " \" %s \" : Escaped identifiers or regular identifiers \
309314 having an integer suffix with leading zeros \
310315 are not allowed for bound variable names." id;
311316 let v = new_tvar id in
Original file line number Diff line number Diff line change 1+ require bool ;
You can’t perform that action at this time.
0 commit comments