Skip to content

Commit

Permalink
Remove cobol_ptree.ml
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Feb 1, 2024
1 parent 733155c commit db11567
Show file tree
Hide file tree
Showing 73 changed files with 263 additions and 285 deletions.
2 changes: 1 addition & 1 deletion src/lsp/cobol_data/item.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ let qualname = function

(** Note: may be a no-op *)
let pp_item_qualname ?(leading = Fmt.nop) ppf item =
Fmt.(option (leading ++ Cobol_ptree.pp_qualname')) ppf (qualname item)
Fmt.(option (leading ++ Cobol_ptree.Types.pp_qualname')) ppf (qualname item)
4 changes: 2 additions & 2 deletions src/lsp/cobol_data/memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ let show_elementary_size = Pretty.to_string "%a" pp_elementary_size
(* --- *)

type symbolic_var =
| Valof of Cobol_ptree.qualname
| Valof of Cobol_ptree.Types.qualname
[@@deriving ord]

let pp_symbolic_var ppf = function
| Valof qn ->
Pretty.print ppf "@[(valof@;<1 2>%a)@]" Cobol_ptree.pp_qualname qn
Pretty.print ppf "@[(valof@;<1 2>%a)@]" Cobol_ptree.Types.pp_qualname qn
let show_symbolic_var = Pretty.to_string "%a" pp_symbolic_var

module AE =
Expand Down
6 changes: 3 additions & 3 deletions src/lsp/cobol_data/memory.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type elementary_size =
[@@deriving show, ord]

type symbolic_var = private
| Valof of Cobol_ptree.qualname
| Valof of Cobol_ptree.Types.qualname
[@@deriving show, ord]

type factor
Expand All @@ -41,11 +41,11 @@ exception NOT_SCALAR of [ `Vars of symbolic_var Cobol_common.Basics.NEL.t
(* --- *)

val int: int -> factor
val valof: Cobol_ptree.qualname -> factor
val valof: Cobol_ptree.Types.qualname -> factor

val point_size: size (* null-size *)
val const_size: int -> size
val valof_size: Cobol_ptree.qualname -> size
val valof_size: Cobol_ptree.Types.qualname -> size
val elementary_size: elementary_size -> size
val bit_size: size
val byte_size: size
Expand Down
30 changes: 15 additions & 15 deletions src/lsp/cobol_data/printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ open Cobol_common.Srcloc.INFIX
let pp_offset = Memory.pp_offset
let pp_size = Memory.pp_size

let pp_int' = Cobol_ptree.pp_with_loc Fmt.int
let pp_int' = Cobol_ptree.Types.pp_with_loc Fmt.int
let pp_int'_opt = Fmt.option pp_int'
let pp_qualname'_opt = Fmt.option Cobol_ptree.pp_qualname'
let pp_qualname'_list = Fmt.(hbox (list ~sep:comma Cobol_ptree.pp_qualname'))
(* Pretty.list ~fopen:"@[<h>" ~fsep:",@;" ~fclose:"@]" Cobol_ptree.pp_qualname' *)
let pp_literal'_opt = Fmt.option Cobol_ptree.pp_literal'
let pp_literal'_list = Fmt.list Cobol_ptree.pp_literal'
let pp_qualname'_opt = Fmt.option Cobol_ptree.Types.pp_qualname'
let pp_qualname'_list = Fmt.(hbox (list ~sep:comma Cobol_ptree.Types.pp_qualname'))
(* Pretty.list ~fopen:"@[<h>" ~fsep:",@;" ~fclose:"@]" Cobol_ptree.Types.pp_qualname' *)
let pp_literal'_opt = Fmt.option Cobol_ptree.Types.pp_literal'
let pp_literal'_list = Fmt.list Cobol_ptree.Types.pp_literal'

(* usage *)

Expand Down Expand Up @@ -100,7 +100,7 @@ and pp_depending_span: depending_span Pretty.printer =
T Fmt.(styled `Yellow @@ any "depending-span");
T (Fmt.field "min_occurs" (fun x -> x.occurs_depending_min) pp_int');
T (Fmt.field "max_occurs" (fun x -> x.occurs_depending_max) pp_int');
T (Fmt.field "depending" (fun x -> x.occurs_depending) Cobol_ptree.pp_qualname');
T (Fmt.field "depending" (fun x -> x.occurs_depending) Cobol_ptree.Types.pp_qualname');
]

and pp_dynamic_span: dynamic_span Pretty.printer =
Expand Down Expand Up @@ -137,7 +137,7 @@ let rec pp_item_definition: item_definition Pretty.printer = fun ppf -> function
| Table def -> pp_table_definition ppf def

and pp_item_definition': item_definition with_loc Pretty.printer = fun ppf ->
Cobol_ptree.pp_with_loc pp_item_definition ppf
Cobol_ptree.Types.pp_with_loc pp_item_definition ppf

and pp_item_definitions: item_definitions Pretty.printer = fun ppf defs ->
NEL.pp ~fopen:"" ~fsep:"" ~fclose:"" pp_item_definition' ppf defs
Expand Down Expand Up @@ -169,7 +169,7 @@ and pp_field_definition: field_definition Pretty.printer = fun ppf x ->
] ppf x

and pp_field_definition': field_definition with_loc Pretty.printer = fun ppf ->
Cobol_ptree.pp_with_loc pp_field_definition ppf
Cobol_ptree.Types.pp_with_loc pp_field_definition ppf

(* and pp_field_definitions: field_definitions Pretty.printer = fun ppf defs -> *)
(* NEL.pp ~fopen:"" ~fsep:"" ~fclose:"" pp_field_definition' ppf defs *)
Expand Down Expand Up @@ -208,20 +208,20 @@ and pp_table_definition: table_definition Pretty.printer = fun ppf x ->
] ppf x

and pp_table_definition': table_definition with_loc Pretty.printer = fun ppf ->
Cobol_ptree.pp_with_loc pp_table_definition ppf
Cobol_ptree.Types.pp_with_loc pp_table_definition ppf


(* condition-names *)

and pp_condition_name: condition_name Pretty.printer =
Pretty.record_with_conditional_fields [
T (Fmt.field "qualname" (fun r -> r.condition_name_qualname)
Cobol_ptree.pp_qualname');
Cobol_ptree.Types.pp_qualname');
T (Fmt.field "values" (fun _ -> "...") Fmt.string);
]

and pp_condition_name': condition_name with_loc Pretty.printer = fun ppf ->
Cobol_ptree.pp_with_loc pp_condition_name ppf
Cobol_ptree.Types.pp_with_loc pp_condition_name ppf

and pp_condition_names: condition_names Pretty.printer = fun ppf ->
Fmt.(list ~sep:nop) pp_condition_name' ppf
Expand All @@ -240,8 +240,8 @@ let pp_renamed_item_layout: renamed_item_layout Pretty.printer = fun ppf -> func

let pp_record_renaming: record_renaming Pretty.printer =
Pretty.record_with_conditional_fields [
T (Fmt.field "qualname" (fun r -> r.renaming_name) Cobol_ptree.pp_qualname');
T (Fmt.field "from" (fun r -> r.renaming_from) Cobol_ptree.pp_qualname');
T (Fmt.field "qualname" (fun r -> r.renaming_name) Cobol_ptree.Types.pp_qualname');
T (Fmt.field "from" (fun r -> r.renaming_from) Cobol_ptree.Types.pp_qualname');
C ((fun r -> r.renaming_thru <> None),
Fmt.field "thru" (fun r -> r.renaming_thru) pp_qualname'_opt);
T (Fmt.field "offset" (fun r -> r.renaming_offset) Memory.pp_offset);
Expand All @@ -250,7 +250,7 @@ let pp_record_renaming: record_renaming Pretty.printer =
]

let pp_record_renaming': record_renaming with_loc Pretty.printer = fun ppf ->
Cobol_ptree.pp_with_loc pp_record_renaming ppf
Cobol_ptree.Types.pp_with_loc pp_record_renaming ppf

let pp_record_renamings: record_renamings Pretty.printer = fun ppf ->
Fmt.(list ~sep:nop) pp_record_renaming' ppf
Expand Down
46 changes: 23 additions & 23 deletions src/lsp/cobol_data/types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ type usage =
| Bit of (* [`boolean] *) picture
| Display of (* [any] *) picture
| Float_binary of { width: [`W32|`W64|`W128]; (* +COB2002 *)
endian: Cobol_ptree.endianness_mode }
endian: Cobol_ptree.Types.endianness_mode }
| Float_decimal of { width: [`W16 | `W34]; (* +COB2002 *)
endian: Cobol_ptree.endianness_mode;
encoding: Cobol_ptree.encoding_mode }
endian: Cobol_ptree.Types.endianness_mode;
encoding: Cobol_ptree.Types.encoding_mode }
| Float_extended (* +COB2002 *)
| Float_long (* +COB2002 *)
| Float_short (* +COB2002 *)
| Function_pointer of Cobol_ptree.name with_loc (* tmp *)
| Function_pointer of Cobol_ptree.Types.name with_loc (* tmp *)
| Index
| National of (* [any] *) picture
| Object_reference of Cobol_ptree.object_reference_kind option (* tmp *)
| Object_reference of Cobol_ptree.Types.object_reference_kind option (* tmp *)
| Packed_decimal of (* [`numeric] *) picture
| Pointer of Cobol_ptree.name with_loc option (* tmp *)
| Program_pointer of Cobol_ptree.name with_loc option (* tmp *)
| Pointer of Cobol_ptree.Types.name with_loc option (* tmp *)
| Program_pointer of Cobol_ptree.Types.name with_loc option (* tmp *)
and signedness = { signed: bool }

type data_storage =
Expand Down Expand Up @@ -84,8 +84,8 @@ and item_definition =

and field_definition =
{
field_qualname: Cobol_ptree.qualname with_loc option;
field_redefines: Cobol_ptree.qualname with_loc option; (* redef only *)
field_qualname: Cobol_ptree.Types.qualname with_loc option;
field_redefines: Cobol_ptree.Types.qualname with_loc option; (* redef only *)
field_leading_ranges: table_range list;
field_offset: Memory.offset; (** offset w.r.t record address *)
field_size: Memory.size;
Expand All @@ -99,7 +99,7 @@ and field_layout =
| Elementary_field of
{
usage: usage;
init_value: Cobol_ptree.literal with_loc option;
init_value: Cobol_ptree.Types.literal with_loc option;
}
| Struct_field of
{
Expand All @@ -112,14 +112,14 @@ and table_definition =
table_offset: Memory.offset;
table_size: Memory.size;
table_range: table_range;
table_init_values: Cobol_ptree.literal with_loc list; (* list for now *)
table_redefines: Cobol_ptree.qualname with_loc option; (* redef only *)
table_init_values: Cobol_ptree.Types.literal with_loc list; (* list for now *)
table_redefines: Cobol_ptree.Types.qualname with_loc option; (* redef only *)
table_redefinitions: item_redefinitions;
}
and table_range =
{
range_span: span;
range_indexes: Cobol_ptree.qualname with_loc list;
range_indexes: Cobol_ptree.Types.qualname with_loc list;
}
and span =
| Fixed_span of fixed_span (* OCCURS _ TIMES *)
Expand All @@ -134,11 +134,11 @@ and depending_span =
{
occurs_depending_min: int with_loc; (* int for now *)
occurs_depending_max: int with_loc; (* ditto *)
occurs_depending: Cobol_ptree.qualname with_loc;
occurs_depending: Cobol_ptree.Types.qualname with_loc;
}
and dynamic_span =
{
occurs_dynamic_capacity: Cobol_ptree.qualname with_loc option;
occurs_dynamic_capacity: Cobol_ptree.Types.qualname with_loc option;
occurs_dynamic_capacity_min: int with_loc option;
occurs_dynamic_capacity_max: int with_loc option;
occurs_dynamic_initialized: bool with_loc;
Expand All @@ -147,8 +147,8 @@ and dynamic_span =
and condition_names = condition_name with_loc list
and condition_name =
{
condition_name_qualname: Cobol_ptree.qualname with_loc;
condition_name_item: Cobol_ptree.condition_name_item; (* for now *)
condition_name_qualname: Cobol_ptree.Types.qualname with_loc;
condition_name_item: Cobol_ptree.Types.condition_name_item; (* for now *)
}

(** Note: RENAMES could be represented by simply adding an (optional,
Expand All @@ -165,12 +165,12 @@ and condition_name =
and record_renamings = record_renaming with_loc list
and record_renaming =
{
renaming_name: Cobol_ptree.qualname with_loc;
renaming_name: Cobol_ptree.Types.qualname with_loc;
renaming_layout: renamed_item_layout;
renaming_offset: Memory.offset;
renaming_size: Memory.size;
renaming_from: Cobol_ptree.qualname with_loc;
renaming_thru: Cobol_ptree.qualname with_loc option;
renaming_from: Cobol_ptree.Types.qualname with_loc;
renaming_thru: Cobol_ptree.Types.qualname with_loc option;
}
and renamed_item_layout =
| Renamed_elementary of
Expand All @@ -184,8 +184,8 @@ and renamed_item_layout =

(* type data_const_record = *)
(* { *)
(* const_name: Cobol_ptree.name with_loc; *)
(* const_descr: Cobol_ptree.constant_item_descr; *)
(* const_name: Cobol_ptree.Types.name with_loc; *)
(* const_descr: Cobol_ptree.Types.constant_item_descr; *)
(* const_layout: const_layout; *)
(* } *)

Expand All @@ -210,7 +210,7 @@ type data_definition =
{
record: record; (* record where [table] is defined *)
table: table_definition with_loc; (* table whose index it is *)
qualname: Cobol_ptree.qualname with_loc; (* fully qualified name *)
qualname: Cobol_ptree.Types.qualname with_loc; (* fully qualified name *)
}

(* screen: "_ OCCURS n TIMES" only. Max 2 dimensions. *)
18 changes: 9 additions & 9 deletions src/lsp/cobol_data_old/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ open Types
* entry arguments *)

module Names = Set.Make (struct
type t = Cobol_ptree.name
type t = Cobol_ptree.Types.name
let compare = String.compare
end)

module DATA_ITEM = struct
type condition = {
target: Cobol_ptree.qualname;
values: Cobol_ptree.condition_name_value list;
target: Cobol_ptree.Types.qualname;
values: Cobol_ptree.Types.condition_name_value list;
} [@@deriving show]

type t =
{ name: Cobol_ptree.name;
{ name: Cobol_ptree.Types.name;
typ: data_type option;
size: int;
global: bool;
value: Cobol_ptree.data_value_clause option;
renames: Cobol_ptree.qualname list;
value: Cobol_ptree.Types.data_value_clause option;
renames: Cobol_ptree.Types.qualname list;
condition: condition option;
redefines: Cobol_ptree.qualname option;
constant: Cobol_ptree.constant_value option; }
redefines: Cobol_ptree.Types.qualname option;
constant: Cobol_ptree.Types.constant_value option; }
[@@deriving show]

let make name =
Expand All @@ -71,7 +71,7 @@ end

module PROG_ENV = struct
type t =
{ name: Cobol_ptree.name;
{ name: Cobol_ptree.Types.name;
parent_prog: t option;
data_items: DATA_ITEM.t Qualmap.t;
currency_signs: Cobol_common.Basics.CharSet.t;
Expand Down
6 changes: 3 additions & 3 deletions src/lsp/cobol_data_old/group.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(* NB: needs quite a bit of rework and cleanup; validation should also be moved
to `Cobol_typeck`. *)

open Cobol_ptree
open Cobol_ptree.Types
open Cobol_common.Srcloc.TYPES
open Cobol_common.Srcloc.INFIX
(* open Pictured_ast.Data_sections *)
Expand Down Expand Up @@ -303,8 +303,8 @@ let group_range (module Diags: Cobol_common.Diagnostics.STATEFUL) first last gro
(note that the major qualifier is first and the minor is last). *)
let list_of_qualname qualname =
let rec aux acc = function
| Cobol_ptree.Qual(n, qn) -> aux (n::acc) qn
| Cobol_ptree.Name n -> n::acc
| Cobol_ptree.Types.Qual(n, qn) -> aux (n::acc) qn
| Cobol_ptree.Types.Name n -> n::acc
in
aux [] qualname

Expand Down
4 changes: 2 additions & 2 deletions src/lsp/cobol_data_old/group.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(**************************************************************************)

(** This module implements a hierarchical version of cobol data items.*)
open Cobol_ptree
open Cobol_ptree.Types
(* open Pictured_ast.Data_sections *)
open Cobol_common.Srcloc.TYPES

Expand All @@ -35,5 +35,5 @@ val pp_data_group_list: Format.formatter -> t list -> unit
(** Convert a list of located {!t working_item_descr_entry} to a list of {!t
t}*)
val of_working_item_descrs
: Cobol_ptree.working_item_descr with_loc list
: Cobol_ptree.Types.working_item_descr with_loc list
-> t list Cobol_common.Diagnostics.with_diags
2 changes: 1 addition & 1 deletion src/lsp/cobol_data_old/mangling.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(**************************************************************************)

open Cobol_common.Srcloc.INFIX
open Cobol_ptree
open Cobol_ptree.Types

(* TODO: Don't require naming of fillers to avoid this kind of exceptions. *)
exception Not_mangled
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/cobol_data_old/mangling.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(** This module aims to implement mangling functions for the COBOL AST.*)


open Cobol_ptree
open Cobol_ptree.Types

(** This exception is raised when a not mangled name is given in a context where it is expected for
the name to be mangled *)
Expand Down
4 changes: 2 additions & 2 deletions src/lsp/cobol_data_old/qualmap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
(* *)
(**************************************************************************)

open Cobol_ptree
open Cobol_ptree.Types
open Cobol_common.Srcloc.INFIX

module QUAL_NAME = struct
type t = qualname [@@deriving show]

let compare = Cobol_ptree.compare_qualname
let compare = Cobol_ptree.Types.compare_qualname

end

Expand Down
2 changes: 1 addition & 1 deletion src/lsp/cobol_data_old/qualmap.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(* *)
(**************************************************************************)

open Cobol_ptree
open Cobol_ptree.Types

type 'a t [@@deriving show]

Expand Down
Loading

0 comments on commit db11567

Please sign in to comment.