Skip to content

Commit

Permalink
Simplify Hmhi and Hmh
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Evans committed Aug 21, 2024
1 parent aa76e02 commit 1313434
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 129 deletions.
18 changes: 6 additions & 12 deletions bootstrap/bin/hocc/Parse.hmh
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,9 @@ type nonterm_ident =
| Matter of {token_: Scan.Token.t; matter: nonterm_matter}
| MatterEpsilon
and nonterm_hmh =
| Hmh of {prelude: nonterm_matter; hocc_: nonterm_hocc; postlude: nonterm_matter;
eoi: Scan.Token.t}
| Hmh of {prelude: nonterm_matter; hocc_: nonterm_hocc; postlude: nonterm_matter; eoi: token_eoi}
and nonterm_hmhi =
| Hmhi of {prelude: nonterm_matter; hocc_: token_hocc; postlude: nonterm_matter;
eoi: Scan.Token.t}
| Hmhi of {prelude: nonterm_matter; hocc_: token_hocc; postlude: nonterm_matter; eoi: token_eoi}

include hocc
(* hocc-specific keywords *)
Expand Down Expand Up @@ -552,14 +550,10 @@ include hocc
| epsilon -> MatterEpsilon

start Hmh of nonterm_hmh ::=
| prelude:Matter hocc_:Hocc postlude:Matter eoi:EOI ->
let EOI {token_=eoi} = eoi in
Hmh {prelude; hocc_; postlude; eoi}
| prelude:Matter hocc_:Hocc postlude:Matter eoi:EOI -> Hmh {prelude; hocc_; postlude; eoi}

start Hmhi of nonterm_hmhi ::=
| prelude:Matter hocc_:"hocc" postlude:Matter eoi:EOI ->
let EOI {token_=eoi} = eoi in
Hmhi {prelude; hocc_; postlude; eoi}
| prelude:Matter hocc_:"hocc" postlude:Matter eoi:EOI -> Hmhi {prelude; hocc_; postlude; eoi}

let rec scan scanner =
let scanner, scan_token = Scan.next scanner in
Expand Down Expand Up @@ -1663,7 +1657,7 @@ let rec pp_token_hocc (HOCC {token_}) formatter =
|> fmt_semi ~alt ~width
|> Fmt.fmt "postlude=" |> pp_matter postlude
|> fmt_semi ~alt ~width
|> Fmt.fmt "eoi=" |> Scan.Token.pp eoi
|> Fmt.fmt "eoi=" |> pp_token_eoi eoi
|> fmt_rcurly ~alt ~width
and pp_hmh hmh formatter =
fmt_hmh hmh formatter
Expand All @@ -1679,7 +1673,7 @@ let rec pp_token_hocc (HOCC {token_}) formatter =
|> fmt_semi ~alt ~width
|> Fmt.fmt "postlude=" |> pp_matter postlude
|> fmt_semi ~alt ~width
|> Fmt.fmt "eoi=" |> Scan.Token.pp eoi
|> Fmt.fmt "eoi=" |> pp_token_eoi eoi
|> fmt_rcurly ~alt ~width
and pp_hmhi hmhi formatter =
fmt_hmhi hmhi formatter
Expand Down
Loading

0 comments on commit 1313434

Please sign in to comment.