Skip to content

Commit

Permalink
Fix ppxlib stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Aug 29, 2023
1 parent b443407 commit db7beeb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
22 changes: 8 additions & 14 deletions packages/reason-css-parser/ppx/Generate.re
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
open Ppxlib;

module Ast_helper = Ppxlib.Ast_helper;

module Make = (Ast_builder: Ppxlib.Ast_builder.S) => {
open Ast_builder;
module Make = (Builder: Ppxlib.Ast_builder.S) => {
module Ast_helper = Ppxlib_ast.Ast_helper;
open Ppxlib;
open Builder;
open Css_spec_parser;

let txt = txt => {Location.loc: Ast_builder.loc, txt};
let txt = txt => {Location.loc: Builder.loc, txt};

let kebab_case_to_snake_case = name =>
name |> String.split_on_char('-') |> String.concat("_");
Expand Down Expand Up @@ -248,11 +246,8 @@ module Make = (Ast_builder: Ppxlib.Ast_builder.S) => {

/* TODO: Move this to Standard and use as ppx_runtime */
let standard_types = {
open Ppxlib.Ast_builder.Default;

let type_ = (~kind=Parsetree.Ptype_abstract, name, core_type) => {
type_declaration(
~loc=Location.none,
Builder.type_declaration(
~name={txt: name, loc: Location.none},
~params=[],
~cstrs=[],
Expand Down Expand Up @@ -417,8 +412,7 @@ module Make = (Ast_builder: Ppxlib.Ast_builder.S) => {
};
};

let add_types = (~loc, bindings) => {
open Ppxlib;
let add_types = (~loc, bindings): list(Ppxlib.structure_item) => {
let new_bindings =
bindings
|> List.map(value_binding => {
Expand All @@ -438,7 +432,7 @@ module Make = (Ast_builder: Ppxlib.Ast_builder.S) => {
let create_variant_name = (type_name, name) =>
type_name ++ "__make__" ++ name;

let txt = txt => {Location.loc: Ast_builder.loc, txt};
let txt = txt => {Location.loc: Builder.loc, txt};

let construct = (~expr=None, name) =>
pexp_construct(txt(Lident(name)), expr);
Expand Down
4 changes: 2 additions & 2 deletions packages/reason-css-parser/ppx/Reason_css_parser_ppx.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ let expander =
~recursive,
~loc as exprLoc,
~path as _: string,
~arg as _: option(loc(Ppxlib.Longident.t)),
~arg as _: option(loc(Longident.t)),
value: string,
_,
_,
) => {
switch (Css_spec_parser.value_of_string(value)) {
| Some(value: Css_spec_parser.value) =>
module Ast_builder =
Ppxlib.Ast_builder.Make({
Ast_builder.Make({
let loc = exprLoc;
});
module Emit = Generate.Make(Ast_builder);
Expand Down

0 comments on commit db7beeb

Please sign in to comment.