Skip to content

Commit

Permalink
Fixed tylrcore dependency bug & other minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
green726 committed Aug 7, 2024
1 parent dcc7daa commit 5c3afd1
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/ts/Grammar.re
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ let subscript_exp = exp =>
brc(R, "]"),
]);

let assignment_pat =
(
exp: unit => Tylr_core.Regex.t(Sym.t),
pat: unit => Tylr_core.Regex.t(Sym.t),
) =>
let assignment_pat = (exp: unit => Regex.t, pat: unit => Regex.t) =>
seq([pat(), op("="), exp()]);
let array_pat = (exp, pat) =>
seq([
Expand All @@ -86,11 +82,7 @@ let array_pat = (exp, pat) =>
]);

let destruct_pat =
(
exp: unit => Tylr_core.Regex.t(Sym.t),
pat: unit => Tylr_core.Regex.t(Sym.t),
obj_pat: unit => Tylr_core.Regex.t(Sym.t),
) =>
(exp: unit => Regex.t, pat: unit => Regex.t, obj_pat: unit => Regex.t) =>
alt([obj_pat(), array_pat(exp, pat)]);

module type SORT = {
Expand All @@ -103,11 +95,23 @@ module rec ObjectPat: SORT = {
let sort = () => Sort.of_str("ObjectPat");
let atom = () => nt(sort());

let pair_pat =
seq([property_name, c(":"), alt([pat(LHSExp.atom), assignment_pat(Exp.atom, () => pat(LHSExp.atom))])]);
let pair_pat =
seq([
property_name,
c(":"),
alt([
pat(LHSExp.atom),
assignment_pat(Exp.atom, () => pat(LHSExp.atom)),
]),
]);

let obj_assignmnet_pat =
seq([alt([t(Id_lower)]), c("="), Exp.atom(), destruct_pat(Exp.atom, ObjectPat.atom, () => pat(LHSExp.atom))]);
seq([
alt([t(Id_lower)]),
c("="),
Exp.atom(),
destruct_pat(Exp.atom, ObjectPat.atom, () => pat(LHSExp.atom)),
]);

let obj_pat =
seq([
Expand Down Expand Up @@ -372,7 +376,6 @@ and Stat: SORT = {
let sort = () => Sort.of_str("Stat");
let atom = () => nt(sort());

let empty_statement = c(";");
let paren_exp = seq([brc(L, "("), Exp.atom(), brc(R, ")")]);

let stat_block =
Expand Down Expand Up @@ -540,6 +543,7 @@ and Stat: SORT = {

let operand =
alt([
empty_statement,
debugger_statement,
export_statement,
import_statement,
Expand Down Expand Up @@ -610,7 +614,7 @@ and Stat: SORT = {
brc(L, "("),
alt([
t(Id_lower),
destruct_pat(Exp.atom, () => pat(LHSExp.atom)),
destruct_pat(Exp.atom, ObjectPat.atom, () => pat(LHSExp.atom)),
]),
brc(R, ")"),
]),
Expand Down Expand Up @@ -647,6 +651,7 @@ and Stat: SORT = {
p(continue_statement),
p(return_statement),
p(throw_statement),
p(label_statement),
p(operand),
];
}
Expand Down

0 comments on commit 5c3afd1

Please sign in to comment.