Skip to content

Commit

Permalink
Minor tweaks and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nberth committed Oct 5, 2023
1 parent fa0abb5 commit 75119bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
9 changes: 4 additions & 5 deletions src/lsp/cobol_ast/misc_descr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 *)
Expand Down
15 changes: 0 additions & 15 deletions src/lsp/cobol_lsp/lsp_document.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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.{
Expand Down Expand Up @@ -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) =
Expand Down
15 changes: 12 additions & 3 deletions src/lsp/cobol_parser/parser_outputs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 75119bd

Please sign in to comment.