Skip to content

Commit a3642c6

Browse files
committed
[ parser_util ] remove spare unit argument in Location.to_string
1 parent edbbc98 commit a3642c6

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

parser_util/driver.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let string_of_error (location, message, lexeme) =
88
let string_of_error_with_location (location, message, lexeme) =
99
match lexeme with
1010
| "" -> Printf.sprintf "At the end of the input, %s" message
11-
| _ -> Printf.sprintf "On the input '%s' at %s, %s" lexeme (Location.to_string () location) message
11+
| _ -> Printf.sprintf "On the input '%s' at %s, %s" lexeme (Location.to_string location) message
1212

1313
module type PARSER = sig
1414
type token

parser_util/location.ml

+15-14
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ let generated = Generated
1111

1212
open Lexing
1313

14-
let to_string () = function
15-
| Generated -> "<generated>"
16-
| FromSource { loc_start; loc_end } when loc_start.pos_lnum = loc_end.pos_lnum
17-
->
18-
Printf.sprintf "line %d, characters %d-%d"
19-
loc_start.pos_lnum
20-
(loc_start.pos_cnum - loc_start.pos_bol)
21-
(loc_end.pos_cnum - loc_end.pos_bol)
14+
let to_string = function
15+
| Generated ->
16+
"<generated>"
17+
| FromSource { loc_start; loc_end }
18+
when loc_start.pos_lnum = loc_end.pos_lnum ->
19+
Printf.sprintf "line %d, characters %d-%d"
20+
loc_start.pos_lnum
21+
(loc_start.pos_cnum - loc_start.pos_bol)
22+
(loc_end.pos_cnum - loc_end.pos_bol)
2223
| FromSource { loc_start; loc_end } ->
23-
Printf.sprintf
24-
"file %S, line %d, character %d, to line %d, character %d, "
25-
loc_start.pos_fname loc_start.pos_lnum
26-
(loc_start.pos_cnum - loc_start.pos_bol)
27-
loc_end.pos_lnum
28-
(loc_end.pos_cnum - loc_end.pos_bol)
24+
Printf.sprintf
25+
"file %S, line %d, character %d, to line %d, character %d, "
26+
loc_start.pos_fname loc_start.pos_lnum
27+
(loc_start.pos_cnum - loc_start.pos_bol)
28+
loc_end.pos_lnum
29+
(loc_end.pos_cnum - loc_end.pos_bol)
2930

3031
let pp fmt = function
3132
| Generated -> Format.pp_print_string fmt "<generated>"

parser_util/location.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ val of_lexbuf : Lexing.lexbuf -> t
55
val generated : t
66
val pp : Format.formatter -> t -> unit
77
val pp_without_filename : Format.formatter -> t -> unit
8-
val to_string : unit -> t -> string
8+
val to_string : t -> string

slakemoth/bin/main.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ let handle_errors = function
99
Printf.eprintf "ERROR: %s\n" (Parser_util.Driver.string_of_error err);
1010
exit 1
1111
| Error (`Type_error (location, msg)) ->
12-
let msg = Printf.sprintf "Problem at %a: %s"
13-
Ast.Location.to_string location
12+
let msg = Printf.sprintf "Problem at %s: %s"
13+
(Ast.Location.to_string location)
1414
msg
1515
in
1616
prerr_endline msg;

slakemoth/lib/core/type_checker.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ let check_arg_specs global_env arg_specs =
353353
in
354354
match check_duplicates names with
355355
| Some (duplicate, location1, location2) ->
356-
errorf location1 "Parameter name '%s' already used at %a"
356+
errorf location1 "Parameter name '%s' already used at %s"
357357
duplicate
358-
Location.to_string location2
358+
(Location.to_string location2)
359359
| None ->
360360
Ok ()
361361

@@ -411,10 +411,10 @@ let check_declaration (env, commands) = function
411411
constructor_domains)
412412
| existing_domain, previous_location ->
413413
errorf constructor.location
414-
"Constructor '%s' previously defined in domain '%s' at %a"
414+
"Constructor '%s' previously defined in domain '%s' at %s"
415415
constructor.detail
416416
existing_domain
417-
Location.to_string previous_location)
417+
(Location.to_string previous_location))
418418
env.constructor_domains
419419
constructors
420420
in

slakemoth/widget/slakemoth_widget.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ let component configuration =
125125
| Ok commands ->
126126
Ok commands
127127
| Error (`Type_error (location, msg)) ->
128-
Error (Printf.sprintf "Problem at %a: %s"
129-
Ast.Location.to_string location
128+
Error (Printf.sprintf "Problem at %s: %s"
129+
(Ast.Location.to_string location)
130130
msg))
131131
| Error (`Parse err) ->
132132
Error (Parser_util.Driver.string_of_error err)

0 commit comments

Comments
 (0)