forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move toplevel stanza to own module (ocaml#9483)
Signed-off-by: Rudi Grinberg <[email protected]>
- Loading branch information
Showing
7 changed files
with
54 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
open Import | ||
|
||
type t = | ||
{ name : string | ||
; libraries : (Loc.t * Lib_name.t) list | ||
; loc : Loc.t | ||
; pps : Preprocess.Without_instrumentation.t Preprocess.t | ||
} | ||
|
||
include Stanza.Make (struct | ||
type nonrec t = t | ||
|
||
include Poly | ||
end) | ||
|
||
let decode = | ||
let open Dune_lang.Decoder in | ||
fields | ||
(let+ loc = loc | ||
and+ name = field "name" string | ||
and+ libraries = field "libraries" (repeat (located Lib_name.decode)) ~default:[] | ||
and+ pps = | ||
field | ||
"preprocess" | ||
(Dune_lang.Syntax.since Stanza.syntax (2, 5) >>> Preprocess.decode) | ||
~default:Preprocess.No_preprocessing | ||
in | ||
match pps with | ||
| Preprocess.Pps _ | No_preprocessing -> { name; libraries; loc; pps } | ||
| Action (loc, _) | Future_syntax loc -> | ||
User_error.raise | ||
~loc | ||
[ Pp.text | ||
"Toplevel does not currently support action or future_syntax preprocessing." | ||
]) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
open Import | ||
|
||
type t = | ||
{ name : string | ||
; libraries : (Loc.t * Lib_name.t) list | ||
; loc : Loc.t | ||
; pps : Preprocess.Without_instrumentation.t Preprocess.t | ||
} | ||
|
||
include Stanza.S with type t := t | ||
|
||
val decode : t Dune_sexp.Decoder.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters