From 75119bd5d1fa55800836d0d1130ea4f5812f95b7 Mon Sep 17 00:00:00 2001 From: Nicolas Berthier Date: Thu, 5 Oct 2023 16:27:53 +0200 Subject: [PATCH] Minor tweaks and comments --- src/lsp/cobol_ast/misc_descr.ml | 9 ++++----- src/lsp/cobol_lsp/lsp_document.ml | 15 --------------- src/lsp/cobol_parser/parser_outputs.ml | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/lsp/cobol_ast/misc_descr.ml b/src/lsp/cobol_ast/misc_descr.ml index 099a8c4da..3ebf4482a 100644 --- a/src/lsp/cobol_ast/misc_descr.ml +++ b/src/lsp/cobol_ast/misc_descr.ml @@ -656,8 +656,8 @@ let pp_select_clause ppf = function | SelectRecordKey { key; source } -> Fmt.pf ppf "RECORD %a%a" pp_qualname key - Pretty.(list ~fopen:"SOURCE " ~fsep:"@ " ~fclose:"" ~fempty:"" - pp_name') source + (Pretty.list ~fopen:"SOURCE " ~fsep:"@ " ~fclose:"" ~fempty:"" + pp_name') source | SelectRelativeKey n -> Fmt.pf ppf "RELATIVE %a" pp_name' n | SelectReserve n -> Fmt.pf ppf "RESERVE %a" pp_integer n @@ -759,11 +759,10 @@ let pp_comment_entry: comment_entry Pretty.printer = Fmt.(list ~sep:sp string) let pp_informational_paragraph: informational_paragraph Pretty.printer = - Fmt.(any "@[<4>" ++ (* <- indent by 4 to avoid Area A *) + Fmt.(box ~indent:4 @@ (* <- indent by 4 to avoid Area A *) pair ~sep:(any ".@ ") pp_informational_paragraph_header - (pp_with_loc pp_comment_entry) ++ - any "@]") + (pp_with_loc pp_comment_entry)) let pp_informational_paragraphs: informational_paragraphs Pretty.printer = Fmt.(list ~sep:(any "@\n") (* force newlines *) diff --git a/src/lsp/cobol_lsp/lsp_document.ml b/src/lsp/cobol_lsp/lsp_document.ml index 3688a9c04..b387759ec 100644 --- a/src/lsp/cobol_lsp/lsp_document.ml +++ b/src/lsp/cobol_lsp/lsp_document.ml @@ -73,20 +73,6 @@ include TYPES type t = document let uri { textdoc; _ } = Lsp.Text_document.documentUri textdoc -(* let simple_parse ({ project; textdoc; _ } as doc) = *) -(* Cobol_parser.parse_with_artifacts *) -(* ~options:Cobol_parser.Options.{ *) -(* default with *) -(* recovery = EnableRecovery { silence_benign_recoveries = true }; *) -(* } *) -(* ~config:project.cobol_config @@ *) -(* Cobol_preproc.preprocessor *) -(* { init_libpath = Lsp_project.libpath_for ~uri:(uri doc) project; *) -(* init_config = project.cobol_config; *) -(* init_source_format = project.source_format } @@ *) -(* String { contents = Lsp.Text_document.text textdoc; *) -(* filename = Lsp.Uri.to_path (uri doc) } *) - let rewindable_parse ({ project; textdoc; _ } as doc) = Cobol_parser.rewindable_parse_with_artifacts ~options:Cobol_parser.Options.{ @@ -158,7 +144,6 @@ let parse_and_analyze ({ copybook; _ } as doc) = if copybook then (* skip *) { doc with artifacts = no_artifacts; rewinder = None; parsed = None } else - (* extract_parsed_infos doc @@ simple_parse doc *) extract_parsed_infos doc @@ rewindable_parse doc let reparse_and_analyze ?position ({ copybook; rewinder; textdoc; _ } as doc) = diff --git a/src/lsp/cobol_parser/parser_outputs.ml b/src/lsp/cobol_parser/parser_outputs.ml index ecc869dd0..585865c9b 100644 --- a/src/lsp/cobol_parser/parser_outputs.ml +++ b/src/lsp/cobol_parser/parser_outputs.ml @@ -25,8 +25,17 @@ type artifacts = comments: Cobol_preproc.comments; } -type ('a, 'm) output = - | Only: 'a -> ('a, Cobol_common.Behaviors.amnesic) output - | WithArtifacts: 'a * artifacts -> ('a, Cobol_common.Behaviors.eidetic) output +(** The output of parsing functions depends on its memorization abilities: + + - an amnesic parse (when ['memo = Cobol_common.Behaviors.amnesic]) only + returns a parsing result (of type ['a]); + + - an eidetic parse (when ['memo = Cobol_common.Behaviors.eidetic]) + additionally returns some parsing artefacts. *) +type ('result, 'memo) output = + | Only: + 'result -> ('result, Cobol_common.Behaviors.amnesic) output + | WithArtifacts: + 'result * artifacts -> ('result, Cobol_common.Behaviors.eidetic) output type 'm parsed_compilation_group = (PTree.compilation_group option, 'm) output