Skip to content

Commit 03cf06f

Browse files
committed
Rename cobol_preproc/preprocess.ml into cobol_preproc/main.ml
1 parent 29b5666 commit 03cf06f

File tree

12 files changed

+44
-44
lines changed

12 files changed

+44
-44
lines changed

src/lsp/cobol_indent/indent_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let indent_range ~dialect ~source_format ~indent_config ~range ~filename ~conten
2323
Cobol_preproc.Src_format.from_config SFFixed
2424
in
2525
let state =
26-
Cobol_preproc.Preprocess.fold_source_lines ~dialect ~source_format
26+
Cobol_preproc.Main.fold_source_lines ~dialect ~source_format
2727
~on_initial_source_format:(fun src_format st -> { st with src_format })
2828
~on_compiler_directive:(fun _ { payload = cd; _} st ->
2929
match cd with

src/lsp/cobol_lsp/document.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let rewindable_parse ({ project; textdoc; _ } as doc) =
7272
recovery = EnableRecovery { silence_benign_recoveries = true };
7373
config = project.config.cobol_config;
7474
} @@
75-
Cobol_preproc.Preprocess.preprocessor
75+
Cobol_preproc.Main.preprocessor
7676
~options:Cobol_preproc.Options.{
7777
default with
7878
libpath = Project.libpath_for ~uri:(uri doc) project;
@@ -116,7 +116,7 @@ let reparse_and_analyze ?position ({ copybook; rewinder; textdoc; _ } as doc) =
116116
| Some position, Some rewinder ->
117117
check doc @@
118118
Cobol_parser.Main.rewind_and_parse rewinder ~position @@
119-
Cobol_preproc.Preprocess.reset_preprocessor_for_string @@
119+
Cobol_preproc.Main.reset_preprocessor_for_string @@
120120
Lsp.Text_document.text textdoc
121121

122122
(** Creates a record for a document that is not yet parsed or analyzed. *)

src/lsp/cobol_parser/main.ml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ type 'x rewinder =
3838
('x * ('x rewinder)) with_diags;
3939
}
4040
and preprocessor_rewind =
41-
?new_position: Lexing.position -> (Cobol_preproc.Preprocess.preprocessor as 'r) -> 'r
41+
?new_position: Lexing.position -> (Cobol_preproc.Main.preprocessor as 'r) -> 'r
4242
and position =
4343
| Lexing of Lexing.position
4444
| Indexed of { line: int; char: int } (* all starting at 0 *)
4545

4646
type 'm simple_parsing
4747
= ?options:parser_options
48-
-> Cobol_preproc.Preprocess.preprocessor
48+
-> Cobol_preproc.Main.preprocessor
4949
-> (Cobol_ptree.Types.compilation_group option, 'm) output DIAGS.with_diags
5050

5151
type 'm rewindable_parsing
5252
= ?options:parser_options
53-
-> Cobol_preproc.Preprocess.preprocessor
53+
-> Cobol_preproc.Main.preprocessor
5454
-> (((Cobol_ptree.Types.compilation_group option, 'm) output as 'x) *
5555
'x rewinder) DIAGS.with_diags
5656

@@ -78,7 +78,7 @@ type 'm state =
7878
basis (mostly the pre-processor and tokenizer's states). *)
7979
and 'm preproc =
8080
{
81-
pp: Cobol_preproc.Preprocess.t; (* also holds diagnostics *)
81+
pp: Cobol_preproc.Main.preprocessor; (* also holds diagnostics *)
8282
tokzr: 'm Tokzr.state;
8383
persist: 'm persist;
8484
}
@@ -130,21 +130,21 @@ and update_tokzr ps tokzr =
130130
else { ps with preproc = { ps.preproc with tokzr } }
131131

132132
let add_diag diag ({ preproc = { pp; _ }; _ } as ps) =
133-
update_pp ps (Cobol_preproc.Preprocess.add_diag pp diag)
133+
update_pp ps (Cobol_preproc.Main.add_diag pp diag)
134134
let add_diags diags ({ preproc = { pp; _ }; _ } as ps) =
135-
update_pp ps (Cobol_preproc.Preprocess.add_diags pp diags)
135+
update_pp ps (Cobol_preproc.Main.add_diags pp diags)
136136

137137
let all_diags { preproc = { pp; tokzr; _ }; _ } =
138-
DIAGS.Set.union (Cobol_preproc.Preprocess.diags pp) @@ Tokzr.diagnostics tokzr
138+
DIAGS.Set.union (Cobol_preproc.Main.diags pp) @@ Tokzr.diagnostics tokzr
139139

140140
(* --- *)
141141

142142
let rec produce_tokens (ps: _ state as 's) : 's * Text_tokenizer.tokens =
143-
let text, pp = Cobol_preproc.Preprocess.next_chunk ps.preproc.pp in
143+
let text, pp = Cobol_preproc.Main.next_chunk ps.preproc.pp in
144144
let { preproc = { pp; tokzr; _ }; _ } as ps = update_pp ps pp in
145145
assert (text <> []);
146146
(* Note: this is the source format in use at the end of the sentence. *)
147-
let source_format = Cobol_preproc.Preprocess.source_format pp in
147+
let source_format = Cobol_preproc.Main.source_format pp in
148148
match Tokzr.tokenize_text ~source_format tokzr text with
149149
| Error `MissingInputs, tokzr ->
150150
produce_tokens (update_tokzr ps tokzr)
@@ -396,7 +396,7 @@ let on_exn ps e =
396396
let first_stage (ps: 'm state) ~make_checkpoint : ('a, 'm) stage =
397397
let ps, tokens = produce_tokens ps in
398398
let first_pos = match tokens with
399-
| [] -> Cobol_preproc.Preprocess.position ps.preproc.pp
399+
| [] -> Cobol_preproc.Main.position ps.preproc.pp
400400
| t :: _ -> Cobol_common.Srcloc.start_pos ~@t
401401
in
402402
normal ps tokens (make_checkpoint first_pos)
@@ -419,9 +419,9 @@ let aggregate_output (type m) (ps: m state) res
419419
| Eidetic ->
420420
let artifacts =
421421
{ tokens = Tokzr.parsed_tokens ps.preproc.tokzr;
422-
pplog = Cobol_preproc.Preprocess.rev_log ps.preproc.pp;
423-
rev_comments = Cobol_preproc.Preprocess.rev_comments ps.preproc.pp;
424-
rev_ignored = Cobol_preproc.Preprocess.rev_ignored ps.preproc.pp } in
422+
pplog = Cobol_preproc.Main.rev_log ps.preproc.pp;
423+
rev_comments = Cobol_preproc.Main.rev_comments ps.preproc.pp;
424+
rev_ignored = Cobol_preproc.Main.rev_ignored ps.preproc.pp } in
425425
WithArtifacts (res, artifacts)
426426

427427
(** Simple parsing *)
@@ -469,7 +469,7 @@ let init_rewindable_parse ps ~make_checkpoint =
469469

470470
(** Stores a stage as part of the memorized rewindable history events. *)
471471
let save_interim_stage (ps, _, env) (store: _ rewindable_history) =
472-
let preproc_position = Cobol_preproc.Preprocess.position ps.preproc.pp in
472+
let preproc_position = Cobol_preproc.Main.position ps.preproc.pp in
473473
match store with
474474
| store'
475475
when preproc_position.pos_cnum <> preproc_position.pos_bol ->
@@ -516,7 +516,7 @@ let find_history_event_preceding ~position ({ store; _ } as rwps) =
516516
pos
517517
| Indexed { line; char } ->
518518
let ps = rewindable_parser_state rwps in
519-
Cobol_preproc.Preprocess.position_at ~line ~char ps.preproc.pp
519+
Cobol_preproc.Main.position_at ~line ~char ps.preproc.pp
520520
in
521521
let rec aux = function
522522
| [] ->
@@ -560,7 +560,7 @@ let rec rewind_n_parse
560560

561561
let rewindable_parse
562562
: options:_ -> memory:'m memory -> make_checkpoint:_
563-
-> Cobol_preproc.Preprocess.preprocessor
563+
-> Cobol_preproc.Main.preprocessor
564564
-> ((('a option, 'm) output as 'x) * 'x rewinder) with_diags =
565565
fun ~options ~memory ~make_checkpoint pp ->
566566
let res, rwps =
@@ -581,7 +581,7 @@ let parse
581581
(type m)
582582
~(memory: m memory)
583583
?(options = Options.default)
584-
: Cobol_preproc.Preprocess.t ->
584+
: Cobol_preproc.Main.t ->
585585
(Cobol_ptree.Types.compilation_group option, m) output with_diags =
586586
parse_once ~options ~memory
587587
~make_checkpoint:Grammar.Incremental.compilation_group
@@ -593,7 +593,7 @@ let rewindable_parse
593593
(type m)
594594
~(memory: m memory)
595595
?(options = Options.default)
596-
: Cobol_preproc.Preprocess.t ->
596+
: Cobol_preproc.Main.t ->
597597
(((Cobol_ptree.Types.compilation_group option, m) output as 'x) * 'x rewinder)
598598
with_diags =
599599
rewindable_parse ~options ~memory

src/lsp/cobol_parser/main.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ open Outputs
3737
(** Simple parsing functions traverse the inputs once to produce a result. *)
3838
type 'm simple_parsing
3939
= ?options:Options.parser_options
40-
-> Cobol_preproc.Preprocess.t
40+
-> Cobol_preproc.Main.preprocessor
4141
-> (Cobol_ptree.Types.compilation_group option, 'm) output
4242
Cobol_common.Diagnostics.with_diags
4343

@@ -60,7 +60,7 @@ val parse_with_artifacts
6060
{!rewinder} that may then be given to {!rewind_and_parse}. *)
6161
type 'm rewindable_parsing
6262
= ?options:parser_options
63-
-> Cobol_preproc.Preprocess.preprocessor
63+
-> Cobol_preproc.Main.preprocessor
6464
-> (((Cobol_ptree.Types.compilation_group option, 'm) output as 'x) * 'x rewinder)
6565
Cobol_common.Diagnostics.with_diags
6666

@@ -74,7 +74,7 @@ and 'x rewinder
7474
of the input. *)
7575
and preprocessor_rewind =
7676
?new_position:Lexing.position ->
77-
(Cobol_preproc.Preprocess.t as 'r) -> 'r
77+
(Cobol_preproc.Main.t as 'r) -> 'r
7878

7979
(* val rewindable_parse *)
8080
(* : memory:'m memory -> 'm rewindable_parsing *)

src/lsp/superbol_free_lib/command_pp.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ let cmd =
6363
~default: common.preproc_options.source_format }
6464
in
6565
input |>
66-
Cobol_preproc.Preprocess.preprocessor ~options:preproc_options |>
66+
Cobol_preproc.Main.preprocessor ~options:preproc_options |>
6767
Cobol_parser.Main.parse_simple ~options:common.parser_options
6868
in
6969
let my_text = Cobol_preproc.Src_input.from ~filename:file ~f:parse in
@@ -96,7 +96,7 @@ let cmd =
9696
let text =
9797
let common = common_get () in
9898
Cobol_common.Diagnostics.show_n_forget @@
99-
Cobol_preproc.Preprocess.text_of_file file
99+
Cobol_preproc.Main.text_of_file file
100100
~options:common.preproc_options
101101
in
102102
let s =

test/cobol_parsing/parser_testing.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let preproc
2121
=
2222
Cobol_common.Srcloc.TESTING.register_file_contents ~filename contents;
2323
String { filename; contents } |>
24-
Cobol_preproc.Preprocess.preprocessor
24+
Cobol_preproc.Main.preprocessor
2525
~options:Cobol_preproc.Options.{
2626
default with
2727
libpath = [];
@@ -149,7 +149,7 @@ let rewindable_parse
149149
=
150150
let DIAGS.{ result = Only ptree, rewinder; diags } =
151151
String { filename = "prog.cob"; contents = prog } |>
152-
Cobol_preproc.Preprocess.preprocessor
152+
Cobol_preproc.Main.preprocessor
153153
~options:Cobol_preproc.Options.{
154154
verbose; libpath = []; source_format;
155155
config = Option.value config ~default:default.config;
@@ -198,7 +198,7 @@ let iteratively_append_chunks ?config ~f (prog, positions) =
198198
Pretty.(to_string "%S" @@ EzString.after prog (pos.cnum - 1));
199199
succ i,
200200
rewind_n_parse ~f:(f i num_chunks) rewinder pos
201-
(Cobol_preproc.Preprocess.reset_preprocessor_for_string prog)
201+
(Cobol_preproc.Main.reset_preprocessor_for_string prog)
202202
end (1, rewinder) (pairwise positions.pos_anonymous)
203203

204204

@@ -230,7 +230,7 @@ let iteratively_append_chunks_stuttering ?config ~f
230230
Pretty.(to_string "%S" @@ EzString.after prog (pos.cnum - 1));
231231
let rewinder =
232232
rewind_n_parse ~f:(f i num_chunks) rewinder pos
233-
(Cobol_preproc.Preprocess.reset_preprocessor_for_string prog)
233+
(Cobol_preproc.Main.reset_preprocessor_for_string prog)
234234
in
235235
let rewinder =
236236
if i < num_chunks then begin
@@ -241,7 +241,7 @@ let iteratively_append_chunks_stuttering ?config ~f
241241
Fmt.(truncated ~max:30)
242242
Pretty.(to_string "%S" @@ EzString.after prog' (pos.cnum - 1));
243243
rewind_n_parse ~f:(f i num_chunks) rewinder next_pos_1
244-
(Cobol_preproc.Preprocess.reset_preprocessor_for_string prog')
244+
(Cobol_preproc.Main.reset_preprocessor_for_string prog')
245245
end else rewinder
246246
in
247247
succ i, rewinder
@@ -280,13 +280,13 @@ let simulate_cut_n_paste ?config ~f0 ~f ?verbose ?(repeat = 1)
280280
and prog_suffix = EzString.after prog (next_pos.cnum - 1) in
281281
let rewinder =
282282
rewind_n_parse ~f:(fun _ _ -> ()) rewinder pos @@
283-
Cobol_preproc.Preprocess.reset_preprocessor_for_string @@
283+
Cobol_preproc.Main.reset_preprocessor_for_string @@
284284
prog_prefix ^ prog_suffix
285285
in
286286
Pretty.out "Putting it back@.";
287287
let rewinder =
288288
rewind_n_parse ~f:(f chunk_num num_chunks ~ptree0) rewinder pos @@
289-
Cobol_preproc.Preprocess.reset_preprocessor_for_string prog
289+
Cobol_preproc.Main.reset_preprocessor_for_string prog
290290
in
291291
loop (succ i) rewinder
292292
end

test/cobol_preprocessing/preproc_testing.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let preprocess
2424
?(source_format = Cobol_config.Types.(SF SFFixed))
2525
contents =
2626
DIAGS.show_n_forget ~ppf:Fmt.stdout @@
27-
Cobol_preproc.Preprocess.preprocess_input
27+
Cobol_preproc.Main.preprocess_input
2828
~options:Cobol_preproc.Options.{ default with verbose; libpath = [];
2929
source_format } @@
3030
Cobol_preproc.Src_input.String { filename; contents }
@@ -36,7 +36,7 @@ let show_text
3636
contents =
3737
let text =
3838
DIAGS.show_n_forget ~ppf:Fmt.stdout @@
39-
Cobol_preproc.Preprocess.text_of_input
39+
Cobol_preproc.Main.text_of_input
4040
~options:Cobol_preproc.Options.{ default with verbose; libpath = [];
4141
source_format } @@
4242
Cobol_preproc.Src_input.String { filename; contents }
@@ -53,7 +53,7 @@ let show_source_lines
5353
contents
5454
=
5555
DIAGS.show_n_forget ~ppf:Fmt.stdout @@
56-
Cobol_preproc.Preprocess.fold_source_lines ~dialect ~source_format
56+
Cobol_preproc.Main.fold_source_lines ~dialect ~source_format
5757
~f:begin fun lnum line () ->
5858
if with_line_numbers then Pretty.out "@\n%u: " lnum else Pretty.out "@\n";
5959
Pretty.out "%a" Cobol_preproc.Text.pp_text line;
@@ -71,10 +71,10 @@ let show_source_lines
7171
end
7272

7373
let rec show_all_text pp =
74-
match Cobol_preproc.Preprocess.next_chunk pp with
74+
match Cobol_preproc.Main.next_chunk pp with
7575
| { payload = Cobol_preproc.Text.Eof; _ } :: _, _ ->
7676
Cobol_common.Diagnostics.Set.pp Fmt.stdout
77-
(Cobol_preproc.Preprocess.diags pp);
77+
(Cobol_preproc.Main.diags pp);
7878
pp
7979
| text, pp ->
8080
Pretty.out "%a@\n" Cobol_preproc.Text.pp_text text;
@@ -98,12 +98,12 @@ let preprocess_n_then_cut_n_paste_right_of_indicator
9898
Pretty.out "fixed: %a@." show_lines fixed_lines;
9999
Pretty.out " free: %a@." show_lines free_lines;
100100
Cobol_preproc.Src_input.string ~filename fixed_format_contents |>
101-
Cobol_preproc.Preprocess.preprocessor
101+
Cobol_preproc.Main.preprocessor
102102
~options:Cobol_preproc.Options.{ default with verbose; libpath = [];
103103
source_format } |>
104104
show_all_text |>
105-
Cobol_preproc.Preprocess.reset_preprocessor_for_string free_format_contents |>
105+
Cobol_preproc.Main.reset_preprocessor_for_string free_format_contents |>
106106
show_all_text |>
107-
Cobol_preproc.Preprocess.reset_preprocessor_for_string fixed_format_contents |>
107+
Cobol_preproc.Main.reset_preprocessor_for_string fixed_format_contents |>
108108
show_all_text |>
109109
ignore

test/output-tests/gnucobol.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ let do_check_parse (test_filename, contents, _, { check_loc;
190190
let source_format = guess_source_format ~filename ~command:check_command in
191191
let parse_simple input =
192192
input |>
193-
Cobol_preproc.Preprocess.preprocessor
193+
Cobol_preproc.Main.preprocessor
194194
~options:Cobol_preproc.Options.{ default with source_format } |>
195195
Cobol_parser.Main.parse_simple
196196
in

0 commit comments

Comments
 (0)