@@ -70,6 +70,8 @@ type valid_input =
70
70
| Mlmap
71
71
| Cmi
72
72
73
+ let bad_arg s = raise_notrace (Arg. Bad (s))
74
+
73
75
(* * This is per-file based,
74
76
when [ocamlc] [-c -o another_dir/xx.cmi]
75
77
it will return (another_dir/xx)
@@ -111,7 +113,7 @@ let process_file ppf sourcefile =
111
113
Resi
112
114
| _ when ext = Literals. suffix_resast -> Resast
113
115
| _ when ext = Literals. suffix_resiast -> Resiast
114
- | _ -> raise( Arg. Bad ( " don't know what to do with " ^ sourcefile) ) in
116
+ | _ -> bad_arg ( " don't know what to do with " ^ sourcefile) in
115
117
let opref = Compenv. output_prefix sourcefile in
116
118
match input with
117
119
| Re -> handle_reason Ml sourcefile ppf opref
@@ -205,13 +207,13 @@ let define_variable s =
205
207
match Ext_string. split ~keep_empty: true s '=' with
206
208
| [key; v] ->
207
209
if not (Lexer. define_key_value key v) then
208
- raise ( Arg. Bad (" illegal definition: " ^ s) )
209
- | _ -> raise ( Arg. Bad ( " illegal definition: " ^ s) )
210
+ bad_arg (" illegal definition: " ^ s)
211
+ | _ -> bad_arg ( " illegal definition: " ^ s)
210
212
211
213
212
214
let buckle_script_flags : (string * Arg.spec * string) list =
213
215
(" -bs-super-errors" ,
214
- Arg. Unit
216
+ Unit
215
217
(* needs to be set here instead of, say, setting a
216
218
Js_config.better_errors flag; otherwise, when `anonymous` runs, we
217
219
don't have time to set the custom printer before it starts outputting
@@ -222,117 +224,117 @@ let buckle_script_flags : (string * Arg.spec * string) list =
222
224
)
223
225
::
224
226
(" -unboxed-types" ,
225
- Arg. Set Clflags. unboxed_types,
227
+ Set Clflags. unboxed_types,
226
228
" unannotated unboxable types will be unboxed"
227
229
)
228
230
::
229
231
(" -bs-re-out" ,
230
- Arg. Unit (fun _ -> Lazy. force Reason_outcome_printer_main. setup),
232
+ Unit (fun _ -> Lazy. force Reason_outcome_printer_main. setup),
231
233
" Print compiler output in Reason syntax"
232
234
)
233
235
::
234
236
(" -bs-jsx" ,
235
- Arg. Int (fun i ->
236
- (if i <> 3 then raise ( Arg. Bad ( " Not supported jsx version : " ^ string_of_int i) ));
237
+ Int (fun i ->
238
+ (if i <> 3 then bad_arg ( " Not supported jsx version : " ^ string_of_int i));
237
239
Js_config. jsx_version := i),
238
240
" Set jsx version"
239
241
)
240
242
::
241
243
(" -bs-refmt" ,
242
- Arg. String (fun s -> Js_config. refmt := Some s),
244
+ String (fun s -> Js_config. refmt := Some s),
243
245
" Set customized refmt path"
244
246
)
245
247
246
248
::
247
249
(
248
250
" -bs-gentype" ,
249
- Arg. String (fun s -> Clflags. bs_gentype := Some s),
251
+ String (fun s -> Clflags. bs_gentype := Some s),
250
252
" Pass gentype command"
251
253
)
252
254
::
253
255
(" -bs-suffix" ,
254
- Arg. Set Js_config. bs_suffix,
256
+ Set Js_config. bs_suffix,
255
257
" Set suffix to .bs.js"
256
258
)
257
259
::
258
- (" -bs-no-implicit-include" , Arg. Set Clflags. no_implicit_current_dir
260
+ (" -bs-no-implicit-include" , Set Clflags. no_implicit_current_dir
259
261
, " Don't include current dir implicitly" )
260
262
::
261
- (" -bs-read-cmi" , Arg. Unit (fun _ -> Clflags. assume_no_mli := Clflags. Mli_exists ),
263
+ (" -bs-read-cmi" , Unit (fun _ -> Clflags. assume_no_mli := Clflags. Mli_exists ),
262
264
" (internal) Assume mli always exist " )
263
265
::
264
- (" -bs-D" , Arg. String define_variable,
266
+ (" -bs-D" , String define_variable,
265
267
" Define conditional variable e.g, -D DEBUG=true"
266
268
)
267
269
::
268
- (" -bs-unsafe-empty-array" , Arg. Clear Js_config. mono_empty_array,
270
+ (" -bs-unsafe-empty-array" , Clear Js_config. mono_empty_array,
269
271
" Allow [||] to be polymorphic"
270
272
)
271
273
::
272
- (" -nostdlib" , Arg. Set Js_config. no_stdlib,
274
+ (" -nostdlib" , Set Js_config. no_stdlib,
273
275
" Don't use stdlib" )
274
276
::
275
- (" -bs-internal-check" , Arg. Unit (Bs_cmi_load. check ),
277
+ (" -bs-internal-check" , Unit (Bs_cmi_load. check ),
276
278
" Built in check corrupted data"
277
279
)
278
280
::
279
281
(" -bs-list-conditionals" ,
280
- Arg. Unit (fun () -> Lexer. list_variables Format. err_formatter),
282
+ Unit (fun () -> Lexer. list_variables Format. err_formatter),
281
283
" List existing conditional variables" )
282
284
::
283
285
(
284
- " -bs-binary-ast" , Arg. Set Js_config. binary_ast,
286
+ " -bs-binary-ast" , Set Js_config. binary_ast,
285
287
" Generate binary .mli_ast and ml_ast"
286
288
)
287
289
::
288
290
(
289
- " -bs-simple-binary-ast" , Arg. Set Js_config. simple_binary_ast,
291
+ " -bs-simple-binary-ast" , Set Js_config. simple_binary_ast,
290
292
" Generate binary .mliast_simple and mlast_simple"
291
293
)
292
294
::
293
295
(" -bs-syntax-only" ,
294
- Arg. Set Js_config. syntax_only,
296
+ Set Js_config. syntax_only,
295
297
" only check syntax"
296
298
)
297
299
::
298
- (" -bs-no-bin-annot" , Arg. Clear Clflags. binary_annotations,
300
+ (" -bs-no-bin-annot" , Clear Clflags. binary_annotations,
299
301
" disable binary annotations (by default on)" )
300
302
::
301
303
(" -bs-eval" ,
302
- Arg. String (fun s -> eval s ~suffix: Literals. suffix_ml),
304
+ String (fun s -> eval s ~suffix: Literals. suffix_ml),
303
305
" (experimental) Set the string to be evaluated in OCaml syntax"
304
306
)
305
307
::
306
308
(" -e" ,
307
- Arg. String (fun s -> eval s ~suffix: Literals. suffix_re),
309
+ String (fun s -> eval s ~suffix: Literals. suffix_re),
308
310
" (experimental) Set the string to be evaluated in ReasonML syntax"
309
311
)
310
312
::
311
313
(
312
314
" -bs-cmi-only" ,
313
- Arg. Set Js_config. cmi_only,
315
+ Set Js_config. cmi_only,
314
316
" Stop after generating cmi file"
315
317
)
316
318
::
317
319
(
318
320
" -bs-cmi" ,
319
- Arg. Set Js_config. force_cmi,
321
+ Set Js_config. force_cmi,
320
322
" Not using cached cmi, always generate cmi"
321
323
)
322
324
::
323
325
(" -bs-cmj" ,
324
- Arg. Set Js_config. force_cmj,
326
+ Set Js_config. force_cmj,
325
327
" Not using cached cmj, always generate cmj"
326
328
)
327
329
::
328
330
(
329
331
" -as-ppx" ,
330
- Arg. Set Js_config. as_ppx,
332
+ Set Js_config. as_ppx,
331
333
" As ppx for editor integration"
332
334
)
333
335
::
334
336
(" -bs-g" ,
335
- Arg. Unit
337
+ Unit
336
338
(fun _ -> Js_config. debug := true ;
337
339
Lexer. replace_directive_bool " DEBUG" true
338
340
),
@@ -341,70 +343,70 @@ let buckle_script_flags : (string * Arg.spec * string) list =
341
343
::
342
344
(
343
345
" -bs-sort-imports" ,
344
- Arg. Set Js_config. sort_imports,
346
+ Set Js_config. sort_imports,
345
347
" Sort the imports by lexical order so the output will be more stable (default false)"
346
348
)
347
349
::
348
350
( " -bs-no-sort-imports" ,
349
- Arg. Clear Js_config. sort_imports,
351
+ Clear Js_config. sort_imports,
350
352
" No sort (see -bs-sort-imports)"
351
353
)
352
354
::
353
355
(" -bs-package-name" ,
354
- Arg. String Js_packages_state. set_package_name,
356
+ String Js_packages_state. set_package_name,
355
357
" set package name, useful when you want to produce npm packages" )
356
358
::
357
359
( " -bs-ns" ,
358
- Arg. String Js_packages_state. set_package_map,
360
+ String Js_packages_state. set_package_map,
359
361
" set package map, not only set package name but also use it as a namespace"
360
362
)
361
363
::
362
364
(" -bs-no-version-header" ,
363
- Arg. Set Js_config. no_version_header,
365
+ Set Js_config. no_version_header,
364
366
" Don't print version header"
365
367
)
366
368
::
367
369
(" -bs-package-output" ,
368
- Arg. String
370
+ String
369
371
Js_packages_state. update_npm_package_path,
370
372
" set npm-output-path: [opt_module]:path, for example: 'lib/cjs', 'amdjs:lib/amdjs', 'es6:lib/es6' " )
371
373
::
372
374
(" -bs-no-builtin-ppx" ,
373
- Arg. Set Js_config. no_builtin_ppx,
375
+ Set Js_config. no_builtin_ppx,
374
376
" disable built-in ppx (internal use)" )
375
377
::
376
378
(" -bs-cross-module-opt" ,
377
- Arg. Set Js_config. cross_module_inline,
379
+ Set Js_config. cross_module_inline,
378
380
" enable cross module inlining(experimental), default(false)" )
379
381
::
380
382
(" -bs-no-cross-module-opt" ,
381
- Arg. Clear Js_config. cross_module_inline,
383
+ Clear Js_config. cross_module_inline,
382
384
" disable cross module inlining(experimental)" )
383
385
::
384
386
(" -bs-diagnose" ,
385
- Arg. Set Js_config. diagnose,
387
+ Set Js_config. diagnose,
386
388
" More verbose output" )
387
389
::
388
390
(" -bs-no-check-div-by-zero" ,
389
- Arg. Clear Js_config. check_div_by_zero,
391
+ Clear Js_config. check_div_by_zero,
390
392
" unsafe mode, don't check div by zero and mod by zero" )
391
393
::
392
394
(" -bs-noassertfalse" ,
393
- Arg. Set Clflags. no_assert_false,
395
+ Set Clflags. no_assert_false,
394
396
" no code for assert false"
395
397
)
396
398
::
397
399
(" -bs-loc" ,
398
- Arg. Set Clflags. dump_location,
400
+ Set Clflags. dump_location,
399
401
" dont display location with -dtypedtree, -dparsetree"
400
402
)
401
403
::
402
- (" -impl" , Arg. String
404
+ (" -impl" , String
403
405
(fun file -> Js_config. js_stdout := false ; impl file ),
404
406
" <file> Compile <file> as a .ml file"
405
407
)
406
408
::
407
- (" -intf" , Arg. String
409
+ (" -intf" , String
408
410
(fun file -> Js_config. js_stdout := false ; intf file),
409
411
" <file> Compile <file> as a .mli file" )
410
412
(* :: Ocaml_options.mk__ anonymous *)
@@ -448,7 +450,7 @@ let _ : unit =
448
450
~target: output
449
451
Ppx_entry. rewrite_implementation
450
452
Ppx_entry. rewrite_signature
451
- | _ -> raise_notrace ( Arg. Bad " Wrong format when use -as-ppx" )
453
+ | _ -> bad_arg " Wrong format when use -as-ppx"
452
454
end
453
455
with x ->
454
456
begin
0 commit comments