@@ -224,6 +224,8 @@ and apply_compiler_directive ({ reader; pplog; _ } as lp)
224
224
(match Src_reader. with_source_format sf reader with
225
225
| Ok reader -> with_reader lp reader
226
226
| Error e -> add_error lp e)
227
+ | CDir_control_section -> (* nothing to do here *)
228
+ lp
227
229
| CDir_preproc preproc_directive ->
228
230
apply_preproc_directive lp (preproc_directive &@ loc)
229
231
@@ -324,15 +326,18 @@ and process_preproc_phrase ({ persist = { pparser = (module Pp);
324
326
~error: (fun e -> `ReplaceDone (add_error lp e,
325
327
List. rev rev_prefix, suffix))
326
328
| Header (header , { prefix = rev_prefix ; phrase; suffix } ) ->
327
- let prefix = match header with
329
+ let prefix, lp = match header with
328
330
| ControlDivision
329
331
| IdentificationDivision ->
330
332
(* keep phrases that are further syntax-checked by the parser, and
331
333
used to perform dialect-related checks there. *)
332
- List. rev_append rev_prefix phrase
334
+ List. rev_append rev_prefix phrase, lp
333
335
| SubstitutionSection ->
334
- (* discard this phrase, which is not checked by the parser *)
335
- List. rev rev_prefix
336
+ (* discard this phrase, which is not checked by the parser; keep it
337
+ in pplog anyways, so as to keep its location for later use. *)
338
+ let loc = Option. get @@ Cobol_common.Srcloc. concat_locs phrase in
339
+ let section = Preproc_directives. CDir_control_section &@ loc in
340
+ List. rev rev_prefix, apply_compiler_directive lp section
336
341
in
337
342
`ReplaceDone (lp, prefix, suffix)
338
343
| ExecBlock { prefix = rev_prefix ; phrase; suffix } ->
0 commit comments