Module Cobol_preproc

Source format

module Src_format : sig ... end

Text

"Text" refers to the source after manipulations by preprocessor statements.

module Text : sig ... end
module Text_printer : sig ... end

Miscellaneous support modules

module Src_overlay : sig ... end

A source overlay associates complex source code elements with virtual limits of lexing tokens that can be fed to parsers so as to tag ASTs with complex source locations.

module Trace : sig ... end
module Directives : sig ... end
module Diagnostics : sig ... end
module Outputs : sig ... end
module Env : sig ... end

Environment for preprocessing and compilation. Holds definitions of preprocessor constants (preprocessor DEFINES, computation process variables), along with compilation variables (78-level constants).

Main entry points for the processor itself

type input = {
  1. source : source;
  2. filename : string;
}
and source =
  1. | String of string
  2. | Channel of Stdlib.in_channel
module Input : sig ... end
module Options : sig ... end
type preprocessor
val preprocessor : options:Cobol_preproc__.Preproc_options.preproc_options -> Cobol_preproc__.Src_input.t -> preprocessor
val reset_preprocessor_for_string : string -> ?new_position:Stdlib.Lexing.position -> preprocessor -> preprocessor
val diags : preprocessor -> Cobol_preproc__.Preproc_diagnostics.diagnostics
val position : preprocessor -> Stdlib.Lexing.position
val position_at : line:int -> char:int -> preprocessor -> Stdlib.Lexing.position
val input_filename : preprocessor -> string option
val source_format : preprocessor -> Src_format.any
val rev_log : preprocessor -> Cobol_preproc__.Preproc_trace.TYPES.log
val rev_comments : preprocessor -> Text.comments EzCompat.StringMap.t

rev_comments pp associates filenames read by pp (directly or indirectly while processing copybooks) with comments read in each respective file, in reverse order.

As a special rule the returned map always includes an association between "" and the file fed to pp.

rev_ignored pp lists the lexical locations ignored when reading the file given to pp.

val next_chunk : preprocessor -> Text.text * preprocessor

Environment access and manipulation

Binds 78-level constants; managed by the preprocessor as MF allows use of such constants in compilation directives.

Given loc should correspond to the area in the source code where the definition occurs.

val lookup_compilation_variable : preprocessor -> Cobol_preproc__.Preproc_env.VAR.t -> Cobol_preproc__.Preproc_env.TYPES.compilation_variable_definition Cobol_common.Srcloc.TYPES.with_src option
val record_compilation_variable_substitution : preprocessor -> loc:Cobol_common.Srcloc.TYPES.srcloc -> var:Cobol_preproc__.Preproc_env.VAR.t -> def: Cobol_preproc__.Preproc_env.TYPES.compilation_variable_definition Cobol_common.Srcloc.TYPES.with_src -> preprocessor

High-level commands

val lex_input : platform:Cobol_common.Platform.TYPES.platform -> dialect:Cobol_config.dialect -> source_format:Cobol_config.source_format_spec -> ?ppf:Stdlib.Format.formatter -> Cobol_preproc__.Src_input.t -> unit Cobol_preproc__.Preproc_outputs.TYPES.with_diags
val lex_file : platform:Cobol_common.Platform.TYPES.platform -> dialect:Cobol_config.dialect -> source_format:Cobol_config.source_format_spec -> ?ppf:Stdlib.Format.formatter -> string -> unit Cobol_preproc__.Preproc_outputs.TYPES.with_diags
val lex_lib : platform:Cobol_common.Platform.TYPES.platform -> dialect:Cobol_config.dialect -> source_format:Cobol_config.source_format_spec -> lookup_config:Cobol_common.Copybook.TYPES.lookup_config -> ?ppf:Stdlib.Format.formatter -> Cobol_common.Copybook.TYPES.fileloc -> unit Cobol_preproc__.Preproc_outputs.TYPES.with_diags
val fold_source_lines : platform:Cobol_common.Platform.TYPES.platform -> dialect:Cobol_config.dialect -> source_format:Cobol_config.source_format_spec -> ?on_change_of_source_format:(Src_format.any -> 'a -> 'a) -> ?skip_compiler_directives_text:bool -> ?on_compiler_directive: (int -> Cobol_preproc__.Preproc_directives.compiler_directive Cobol_common.Srcloc.TYPES.with_loc -> 'a -> 'a) -> f:(int -> Text.text -> 'a -> 'a) -> Cobol_preproc__.Src_input.t -> 'a -> 'a

fold_source_lines ~dialect ~source_format ~skip_compiler_directives_text ~on_compiler_directive ~on_initial_source_format ~f input acc applies f line_number line acc for each successive source line line of input. line_number gives the line number for line (starting at 1). line is given empty to f if it corresponds to an empty line in the input, or was a line continuation in the case of fixed-width reference format.

When given, on_compiler_directive is called after f has been fed with the text of a compiler directive, with the same line number.

When given, on_change_of_source_format is called each time the source format changes: once at the begining before f has been called, and then once each time a compiler directive that changes the source format is encountered (right after the text is fed to f but before on_compiler_directive is called).

When set, skip_compiler_directives_text (false by default) prevents the text of compiler directives from being fed to f. If given, on_compiler_directive is called as if the text had been fed to f.

Diagnostics resulting from lexing and parsing the input are attached to the returned accumulated value.

val scan_prefix_for_copybook : platform:Cobol_common.Platform.TYPES.platform -> dialect:Cobol_config.dialect -> source_format:Cobol_config.source_format_spec -> Cobol_preproc__.Src_input.t -> [ `Program | `Copybook ]
val preprocess_input : options:Cobol_preproc__.Preproc_options.preproc_options -> ?ppf:Stdlib.Format.formatter -> Cobol_preproc__.Src_input.t -> unit Cobol_preproc__.Preproc_outputs.TYPES.with_diags
val preprocess_file : options:Cobol_preproc__.Preproc_options.preproc_options -> ?ppf:Stdlib.Format.formatter -> string -> unit Cobol_preproc__.Preproc_outputs.TYPES.with_diags
val text_of_file : options:Cobol_preproc__.Preproc_options.preproc_options -> string -> Text.t Cobol_preproc__.Preproc_outputs.TYPES.with_diags
val text_of_input : options:Cobol_preproc__.Preproc_options.preproc_options -> Cobol_preproc__.Src_input.t -> Text.t Cobol_preproc__.Preproc_outputs.TYPES.with_diags