Skip to content

Commit

Permalink
Merge pull request #58 from nberth/more-dialects
Browse files Browse the repository at this point in the history
Add support for more dialects (partially) supported by GnuCOBOL
  • Loading branch information
nberth authored Oct 16, 2023
2 parents 560f57f + 6ca8d6f commit aeed2c6
Show file tree
Hide file tree
Showing 10 changed files with 2,071 additions and 26 deletions.
11 changes: 9 additions & 2 deletions src/lsp/cobol_config/cobol_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,16 @@ let from_dialect (module Diags: DIAGS.STATEFUL) ~strict d =
in
match d with
| DIALECT.Default -> (module Default: T)
| COBOL85 -> load_gnucobol_conf d ~strict:false "cobol85"
| GnuCOBOL -> load_gnucobol_conf d ~strict:false "default"
| COBOL85 -> load_gnucobol_conf d ~strict:false "cobol85"
| COBOL2002 -> load_gnucobol_conf d ~strict:false "COBOL2002"
| COBOL2014 -> load_gnucobol_conf d ~strict:false "COBOL2014"
| ACU -> load_gnucobol_conf d ~strict "acu"
| MicroFocus -> load_gnucobol_conf d ~strict "mf"
| BS2000 -> load_gnucobol_conf d ~strict "bs2000"
| GCOS -> load_gnucobol_conf d ~strict "gcos"
| IBM -> load_gnucobol_conf d ~strict "ibm"
| MicroFocus -> load_gnucobol_conf d ~strict "mf"
| MVS -> load_gnucobol_conf d ~strict "mvs"
| Realia -> load_gnucobol_conf d ~strict "realia"
| RM -> load_gnucobol_conf d ~strict "rm"
| XOpen -> load_gnucobol_conf d ~strict "xopen"
72 changes: 58 additions & 14 deletions src/lsp/cobol_config/types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -297,47 +297,91 @@ and word_spec =

module DIALECT = struct

let all_canonical_names =
[ "default";
"gnucobol"; "microfocus"; "mf"; "acu"; "gcos"; "ibm"; "cobol85";
"GnuCOBOL"; "MicroFocus"; "MF"; "ACU"; "GCOS"; "IBM"; "COBOL85" ]
let all_canonical_names = [
"default";
"gnucobol";

"cobol85";
"cobol2002";
"cobol2014";

"acu";
"bs2000";
"gcos";
"ibm";
"mf";
"mvs";
"realia";
"rm";
"xopen";
]

type t =
| Default
| COBOL85
| GnuCOBOL
| MicroFocus
| COBOL85
| COBOL2002
| COBOL2014
| ACU
| BS2000
| GCOS
| IBM
| MicroFocus
| MVS
| Realia
| RM
| XOpen

let name: t -> string = function
| Default -> "default"
| COBOL85 -> "COBOL85"
| GnuCOBOL -> "GnuCOBOL"
| MicroFocus -> "MicroFocus"

| COBOL85 -> "COBOL85"
| COBOL2002 -> "COBOL2002"
| COBOL2014 -> "COBOL2014"

| ACU -> "ACU"
| BS2000 -> "BS2000"
| GCOS -> "GCOS"
| IBM -> "IBM"
| MicroFocus -> "MicroFocus"
| MVS -> "MVS"
| Realia -> "Realia"
| RM -> "RM"
| XOpen -> "XOpen"

let of_string: string -> t = fun s ->
match String.lowercase_ascii s with
| "default" -> Default
| "cobol85" -> COBOL85
| "gnucobol" -> GnuCOBOL
| "microfocus" | "mf" -> MicroFocus
| "cobol85" -> COBOL85
| "cobol2002" -> COBOL2002
| "cobol2014" -> COBOL2014
| "acu" -> ACU
| "bs2000" -> BS2000
| "gcos" -> GCOS
| "ibm" -> IBM
| "mf" | "microfocus" -> MicroFocus
| "mvs" -> MVS
| "realia" -> Realia
| "rm" -> RM
| "xopen" -> XOpen
| _ -> invalid_arg s

let of_name: string -> t = function
| "COBOL 85" -> COBOL85
| "GnuCOBOL" -> GnuCOBOL (*TODO: or maybe default *)
| "Micro Focus COBOL" | "Micro Focus COBOL (lax)" -> MicroFocus
| "IBM COBOL" | "IBM COBOL (lax)" -> IBM
| "GCOS" | "GCOS (lax)" -> GCOS
| "COBOL 2002" -> COBOL2002
| "COBOL 2014" -> COBOL2014
| "GnuCOBOL" -> GnuCOBOL (*TODO: or maybe default *)
| "ACUCOBOL-GT" | "ACUCOBOL-GT (lax)" -> ACU
| "BS2000 COBOL" | "BS2000 COBOL (lax)" -> BS2000
| "GCOS" | "GCOS (lax)" -> GCOS
| "IBM COBOL" | "IBM COBOL (lax)" -> IBM
| "Micro Focus COBOL" | "Micro Focus COBOL (lax)" -> MicroFocus
| "IBM COBOL for MVS & VM" | "MVS/VM COBOL (lax)" -> MVS
| "CA Realia II" | "CA Realia II (lax)" -> Realia
| "RM-COBOL" | "RM-COBOL (lax)" -> RM
| "X/Open COBOL" -> XOpen
| s -> of_string s

end
Expand Down
996 changes: 996 additions & 0 deletions src/lsp/cobol_parser/grammar_printer.ml

Large diffs are not rendered by default.

Loading

0 comments on commit aeed2c6

Please sign in to comment.