Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 152b8a9

Browse files
committed
Refactor PPX: move across files and clean up exceptions
Move PPX V3 and V4 back to different files. Clean up treatment of exceptions.
1 parent 81e7a52 commit 152b8a9

File tree

6 files changed

+2559
-2641
lines changed

6 files changed

+2559
-2641
lines changed

cli/dune

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
(executable
22
(name res_cli)
33
(public_name rescript)
4+
(modes byte exe)
45
(flags
56
(-open Syntax -open Compilerlibs406)
6-
(:standard -w +a-4-42-40-9-48))
7+
(:standard -w +a-4-42-40-9-48-70))
78
(libraries syntax compilerlibs406))

cli/react_jsx_common.ml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
open Asttypes
2+
open Parsetree
3+
4+
type jsxConfig = {
5+
mutable version: int;
6+
mutable module_: string;
7+
mutable mode: string;
8+
mutable nestedModules: string list;
9+
mutable hasReactComponent: bool;
10+
}
11+
12+
(* Helper method to look up the [@react.component] attribute *)
13+
let hasAttr (loc, _) = loc.txt = "react.component"
14+
15+
(* Iterate over the attributes and try to find the [@react.component] attribute *)
16+
let hasAttrOnBinding {pvb_attributes} =
17+
List.find_opt hasAttr pvb_attributes <> None
18+
19+
let raiseError ~loc msg = Location.raise_errorf ~loc msg
20+
21+
let raiseErrorMultipleReactComponent ~loc =
22+
raiseError ~loc
23+
"Only one component definition is allowed for each module. Move to a \
24+
submodule or other file if necessary."

0 commit comments

Comments
 (0)