Skip to content

Commit

Permalink
Rename 'syntax' to 'dialect'
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Jul 11, 2019
1 parent df2451c commit 8e9252f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions src/module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ module Name = struct
let to_local_lib_name s =
Lib_name.Local.of_string_exn s

let basename n ~(ml_kind : Ml_kind.t) ~(syntax : Dialect.t) =
String.lowercase n ^ Dialect.extension syntax ml_kind
let basename n ~(ml_kind : Ml_kind.t) ~(dialect : Dialect.t) =
String.lowercase n ^ Dialect.extension dialect ml_kind
end

module File = struct
type t =
{ path : Path.t
; syntax : Dialect.t
{ path : Path.t
; dialect : Dialect.t
}

let path t = t.path
Expand All @@ -52,13 +52,13 @@ module File = struct
let path = Path.relative src_dir (Path.basename t.path) in
{ t with path }

let make syntax path = { syntax; path }
let make dialect path = { dialect; path }

let to_dyn { path; syntax } =
let to_dyn { path; dialect } =
let open Dyn.Encoder in
record
[ "path", Path.to_dyn path
; "syntax", Dialect.to_dyn syntax
; "dialect", Dialect.to_dyn dialect
]

end
Expand Down Expand Up @@ -267,7 +267,7 @@ let wrapped_compat t =
let impl =
Some (
{ File.
syntax = Dialect.ocaml
dialect = Dialect.ocaml
; path =
(* Option.value_exn cannot fail because we disallow wrapped
compatibility mode for virtual libraries. That means none of the
Expand Down Expand Up @@ -346,7 +346,7 @@ let decode ~src_dir =
in
let file exists ml_kind =
if exists then
let basename = Name.basename name ~ml_kind ~syntax:Dialect.ocaml in
let basename = Name.basename name ~ml_kind ~dialect:Dialect.ocaml in
Some (File.make Dialect.ocaml (Path.relative src_dir basename))
else
None
Expand Down Expand Up @@ -375,7 +375,7 @@ let pped =

let ml_source =
map_files ~f:(fun ml_kind f ->
match Dialect.ml_suffix f.syntax ml_kind with
match Dialect.ml_suffix f.dialect ml_kind with
| None -> f
| Some suffix ->
let path = Path.extend_basename f.path ~suffix in
Expand Down
4 changes: 2 additions & 2 deletions src/module.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ end

module File : sig
type t =
{ path : Path.t
; syntax : Dialect.t
{ path : Path.t
; dialect : Dialect.t
}

val path : t -> Path.t
Expand Down
12 changes: 6 additions & 6 deletions src/preprocessing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,10 @@ let action_for_pp sctx ~dep_kind ~loc ~expander ~action ~src ~target =

(* Generate rules for the reason modules in [modules] and return a
a new module with only OCaml sources *)
let setup_reason_rules sctx ~dir ~dep_kind ~expander (m : Module.t) =
let setup_dialect_rules sctx ~dir ~dep_kind ~expander (m : Module.t) =
let ml = Module.ml_source m in
Module.iter m ~f:(fun ml_kind f ->
match Dialect.preprocess f.syntax ml_kind with
match Dialect.preprocess f.dialect ml_kind with
| Dialect.Filter.No_filter -> ()
| Action (loc, action) ->
let src = Path.as_in_build_dir_exn f.path in
Expand Down Expand Up @@ -719,7 +719,7 @@ let make sctx ~dir ~expander ~dep_kind ~lint ~preprocess
with
| No_preprocessing ->
(fun m ~lint ->
let ast = setup_reason_rules sctx ~dir ~dep_kind ~expander m in
let ast = setup_dialect_rules sctx ~dir ~dep_kind ~expander m in
if lint then lint_module ~ast ~source:m;
ast)
| Action (loc, action) ->
Expand All @@ -731,7 +731,7 @@ let make sctx ~dir ~expander ~dep_kind ~lint ~preprocess
in
SC.add_rule sctx ~loc ~dir
(preprocessor_deps >>> action))
|> setup_reason_rules sctx ~dir ~dep_kind ~expander
|> setup_dialect_rules sctx ~dir ~dep_kind ~expander
in
if lint then lint_module ~ast ~source:m;
ast)
Expand All @@ -754,7 +754,7 @@ let make sctx ~dir ~expander ~dep_kind ~lint ~preprocess
~standard:(Build.return ["--as-ppx"]))), args)
in
(fun m ~lint ->
let ast = setup_reason_rules sctx ~dir ~dep_kind ~expander m in
let ast = setup_dialect_rules sctx ~dir ~dep_kind ~expander m in
if lint then lint_module ~ast ~source:m;
pped_module ast ~f:(fun ml_kind src dst ->
SC.add_rule sctx ~loc ~dir
Expand Down Expand Up @@ -803,7 +803,7 @@ let make sctx ~dir ~expander ~dep_kind ~lint ~preprocess
in
let pp = Some pp_flags in
(fun m ~lint ->
let ast = setup_reason_rules sctx ~dir ~dep_kind ~expander m in
let ast = setup_dialect_rules sctx ~dir ~dep_kind ~expander m in
if lint then lint_module ~ast ~source:m;
Module.set_pp ast pp)
end)
Expand Down

0 comments on commit 8e9252f

Please sign in to comment.