diff --git a/src/hazel/Sort.re b/src/hazel/Sort.re deleted file mode 100644 index 248f2886..00000000 --- a/src/hazel/Sort.re +++ /dev/null @@ -1,42 +0,0 @@ -[@deriving (show({with_path: false}), sexp, yojson, ord)] -type t = - | Exp - | Pat - | Typ; - -let root = Exp; -let all = [Exp, Pat, Typ]; -// let to_int = -// fun -// | Exp => 0 -// | Pat => 1 -// | Typ => 2; -// let of_int = -// fun -// | 0 => Exp -// | 1 => Pat -// | 2 => Typ -// | _ => raise(Invalid_argument("")); -// let compare = (s1, s2) => Int.compare(to_int(s1), to_int(s2)); -// let lca = (s1, s2) => of_int(Int.min(to_int(s1), to_int(s2))); - -let to_str = - fun - | Typ => "Typ" - | Pat => "Pat" - // | Rul => "Rul" - | Exp => "Exp"; - -let of_str = - fun - | "Typ" => Typ - | "Pat" => Pat - | "Exp" => Exp - | _ => raise(Invalid_argument("Sort.of_string: unrecognized sort")); - -module Ord = { - type nonrec t = t; - let compare = compare; -}; -module Map = Map.Make(Ord); -module Set = Set.Make(Ord); diff --git a/src/prop/Grammar.re b/src/prop/Grammar.re deleted file mode 100644 index db220c3d..00000000 --- a/src/prop/Grammar.re +++ /dev/null @@ -1,71 +0,0 @@ -open Util; - -module Sym = { - include Sym; - type t = Sym.t(Label.t, Sort.t); -}; -module Regex = { - include Regex; - type t = Regex.t(Sym.t); -}; -open Regex; - -let p = (~a: option(Dir.t)=?, r: t) => (a, r); - -let t = (lbl: Label.t) => Regex.atom(Sym.t(lbl)); -let nt = (srt: Sort.t) => Regex.atom(Sym.nt(srt)); - -let c = (~p=Padding.none, s) => t(Label.const(~padding=p, s)); - -module Typ = { - let sort = Sort.of_str("Typ"); - let tbl = []; -}; - -module Pat = { - let sort = Sort.of_str("Pat"); - let tbl = []; -}; - -module Exp = { - let sort = Sort.of_str("Exp"); - let exp = nt(sort); - - [@warning "-32"] - let comma_sep = seq([exp, Star(seq([c(","), exp]))]); - - // let rule = seq([tokc("|"), p, tokc("=>"), e]); - - // let statement = seq([e, tokc(";")]); - // let block = Star(statement); - - let operand = - alt([ - t(Int_lit), - t(Float_lit), - t(Id_lower), - // todo: seq([tokc("("), opt(comma_sep), tokc(")")]), - seq([c("("), exp, c(")")]), - // todo: seq([tokc("["), opt(comma_sep), tokc("]")]), - seq([c("["), exp, c("]")]), - // seq([tokc("case"), e, Star(rule), tokc("end")]), - ]); - - let tokc_alt = ss => alt(List.map(c, ss)); - let add_op = tokc_alt(["+", "+.", "-", "-."]); - let mult_op = tokc_alt(["*", "*.", "/", "/."]); - let neg_op = tokc_alt(["-", "-."]); - - let tbl = [ - p(~a=L, seq([exp, add_op, exp])), - p(~a=L, seq([exp, mult_op, exp])), - p(seq([neg_op, exp])), - p(operand), - ]; -}; - -type t = Sort.Map.t(Prec.Table.t(Regex.t)); -let v = - [Typ.(sort, tbl), Pat.(sort, tbl), Exp.(sort, tbl)] - |> List.to_seq - |> Sort.Map.of_seq; diff --git a/src/prop/dune b/src/prop/dune deleted file mode 100644 index 364a7071..00000000 --- a/src/prop/dune +++ /dev/null @@ -1,24 +0,0 @@ -(include_subdirs unqualified) - -(library - (name tylr_prop_logic) - (libraries util re sexplib) - (implements tylr_core) - (js_of_ocaml - (flags - (:include js-of-ocaml-flags-%{profile}))) - (preprocess - (pps - ppx_let - ppx_sexp_conv - ppx_deriving.show - ppx_deriving.ord - ppx_yojson_conv))) - -(rule - (write-file - js-of-ocaml-flags-dev - "(:standard --debug-info --no-inline --pretty --source-map)")) - -(rule - (write-file js-of-ocaml-flags-release "(:standard)")) diff --git a/src/hazel/Grammar.re b/src/rust/Grammar.re similarity index 63% rename from src/hazel/Grammar.re rename to src/rust/Grammar.re index db220c3d..5ff7f885 100644 --- a/src/hazel/Grammar.re +++ b/src/rust/Grammar.re @@ -27,6 +27,24 @@ module Pat = { let tbl = []; }; +module Stat = { + let sort = Sort.of_str("Stat"); + let stat = nt(sort) + + let tbl = []; +} + +module Item = { + let sort = Sort.of_str("Item"); + let item = nt(sort); + + let tbl = [ + //function declaration will be our item + p(seq([])) + ] +} + + module Exp = { let sort = Sort.of_str("Exp"); let exp = nt(sort); @@ -34,32 +52,17 @@ module Exp = { [@warning "-32"] let comma_sep = seq([exp, Star(seq([c(","), exp]))]); - // let rule = seq([tokc("|"), p, tokc("=>"), e]); - - // let statement = seq([e, tokc(";")]); - // let block = Star(statement); - let operand = alt([ t(Int_lit), t(Float_lit), t(Id_lower), - // todo: seq([tokc("("), opt(comma_sep), tokc(")")]), seq([c("("), exp, c(")")]), - // todo: seq([tokc("["), opt(comma_sep), tokc("]")]), - seq([c("["), exp, c("]")]), - // seq([tokc("case"), e, Star(rule), tokc("end")]), ]); let tokc_alt = ss => alt(List.map(c, ss)); - let add_op = tokc_alt(["+", "+.", "-", "-."]); - let mult_op = tokc_alt(["*", "*.", "/", "/."]); - let neg_op = tokc_alt(["-", "-."]); let tbl = [ - p(~a=L, seq([exp, add_op, exp])), - p(~a=L, seq([exp, mult_op, exp])), - p(seq([neg_op, exp])), p(operand), ]; }; diff --git a/src/prop/Sort.re b/src/rust/Sort.re similarity index 55% rename from src/prop/Sort.re rename to src/rust/Sort.re index 248f2886..9cfe5d17 100644 --- a/src/prop/Sort.re +++ b/src/rust/Sort.re @@ -2,29 +2,21 @@ type t = | Exp | Pat + | Stat + | Item | Typ; -let root = Exp; -let all = [Exp, Pat, Typ]; -// let to_int = -// fun -// | Exp => 0 -// | Pat => 1 -// | Typ => 2; -// let of_int = -// fun -// | 0 => Exp -// | 1 => Pat -// | 2 => Typ -// | _ => raise(Invalid_argument("")); -// let compare = (s1, s2) => Int.compare(to_int(s1), to_int(s2)); -// let lca = (s1, s2) => of_int(Int.min(to_int(s1), to_int(s2))); +let root = Item; +let all = [Exp, Pat, Typ, Item, Stat]; + let to_str = fun | Typ => "Typ" | Pat => "Pat" // | Rul => "Rul" + | Item => "Item" + | Stat => "Stat" | Exp => "Exp"; let of_str = @@ -32,6 +24,8 @@ let of_str = | "Typ" => Typ | "Pat" => Pat | "Exp" => Exp + | "Stat" => Stat + | "Item" => Item | _ => raise(Invalid_argument("Sort.of_string: unrecognized sort")); module Ord = { diff --git a/src/hazel/dune b/src/rust/dune similarity index 95% rename from src/hazel/dune rename to src/rust/dune index 87710548..745c31c8 100644 --- a/src/hazel/dune +++ b/src/rust/dune @@ -1,7 +1,7 @@ (include_subdirs unqualified) (library - (name tylr_hazel) + (name tylr_rust) (libraries util re sexplib) (implements tylr_core) (js_of_ocaml diff --git a/src/web/dune b/src/web/dune index f98c4311..ac12da59 100644 --- a/src/web/dune +++ b/src/web/dune @@ -18,7 +18,7 @@ (executable (name main) (modules Main) - (libraries tylr_web tylr_hazel) + (libraries tylr_web tylr_rust) (modes js) (js_of_ocaml (flags