1
+ (* Copyright (C) 2020 Authors of BuckleScript
2
+ *
3
+ * This program is free software: you can redistribute it and/or modify
4
+ * it under the terms of the GNU Lesser General Public License as published by
5
+ * the Free Software Foundation, either version 3 of the License, or
6
+ * (at your option) any later version.
7
+ *
8
+ * In addition to the permissions granted to you by the LGPL, you may combine
9
+ * or link a "work that uses the Library" with a publicly distributed version
10
+ * of this file to produce a combined library or application, then distribute
11
+ * that combined work under the terms of your choosing, with no requirement
12
+ * to comply with the obligations normally placed on you by section 4 of the
13
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
14
+ * should you choose to use a later version).
15
+ *
16
+ * This program is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU Lesser General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Lesser General Public License
22
+ * along with this program; if not, write to the Free Software
23
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24
+
25
+
26
+ type action_table =
27
+ (Parsetree .expression option -> unit ) Map_string .t
28
+ (* * global configurations below *)
29
+ let common_actions_table :
30
+ (string * (Parsetree. expression option -> unit )) list =
31
+ [
32
+ ]
33
+
34
+
35
+ let structural_config_table : action_table =
36
+ Map_string. of_list
37
+ (( " no_export" ,
38
+ (fun x ->
39
+ Js_config. no_export := (
40
+ match x with
41
+ | Some e -> Ast_payload. assert_bool_lit e
42
+ | None -> true )
43
+ ))
44
+ :: common_actions_table)
45
+
46
+ let signature_config_table : action_table =
47
+ Map_string. of_list common_actions_table
48
+
49
+
50
+ let rec iter_on_bs_config_stru (x :Parsetree.structure ) =
51
+ match x with
52
+ | [] -> ()
53
+ | {pstr_desc = Pstr_attribute (({txt = "bs.config" ; loc} , payload ) as attr )} ::_ ->
54
+ Bs_ast_invariant. mark_used_bs_attribute attr;
55
+ Ext_list. iter (Ast_payload. ident_or_record_as_config loc payload)
56
+ (Ast_payload. table_dispatch structural_config_table)
57
+ | {pstr_desc = Pstr_attribute _ } :: rest ->
58
+ iter_on_bs_config_stru rest
59
+ | non_attr :: _ -> ()
60
+
61
+ let rec iter_on_bs_config_sigi (x :Parsetree.signature ) =
62
+ match x with
63
+ | [] -> ()
64
+ | {psig_desc = Psig_attribute (({txt = "bs.config" ; loc} , payload ) as attr )} ::_ ->
65
+ Bs_ast_invariant. mark_used_bs_attribute attr;
66
+ Ext_list. iter (Ast_payload. ident_or_record_as_config loc payload)
67
+ (Ast_payload. table_dispatch signature_config_table)
68
+ | {psig_desc = Psig_attribute _ } :: rest ->
69
+ iter_on_bs_config_sigi rest
70
+ | non_attr :: _ -> ()
0 commit comments