Skip to content

Commit

Permalink
Simplify Sep*
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Evans committed Aug 21, 2024
1 parent 4d30199 commit aa76e02
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 112 deletions.
30 changes: 12 additions & 18 deletions bootstrap/bin/hocc/Parse.hmh
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ type nonterm_ident =
| Token of {cident: token_cident; token_alias: nonterm_token_alias;
symbol_type0: nonterm_symbol_type0; prec_ref: nonterm_prec_ref}
and nonterm_sep =
| SepLineDelim of {line_delim: Scan.Token.t}
| SepSemi of {semi: Scan.Token.t}
| SepBar of {bar: Scan.Token.t}
| SepLineDelim of {line_delim: token_line_delim}
| SepSemi of {semi: token_semi}
| SepBar of {bar: token_bar}
and nonterm_codes_tl =
| CodesTlSepCode of {sep: nonterm_sep; code: nonterm_code; codes_tl: nonterm_codes_tl}
| CodesTlEpsilon
Expand Down Expand Up @@ -356,15 +356,9 @@ include hocc
Token {cident; token_alias; symbol_type0; prec_ref}

nonterm Sep of nonterm_sep ::=
| line_delim:LINE_DELIM ->
let LINE_DELIM {token_=line_delim} = line_delim in
SepLineDelim {line_delim}
| semi:";" ->
let SEMI {token_=semi} = semi in
SepSemi {semi}
| bar:"|" ->
let BAR {token_=bar} = bar in
SepBar {bar}
| line_delim:LINE_DELIM -> SepLineDelim {line_delim}
| semi:";" -> SepSemi {semi}
| bar:"|" -> SepBar {bar}

nonterm CodesTl of nonterm_codes_tl ::=
| sep:Sep code:Code codes_tl:CodesTl -> CodesTlSepCode {sep; code; codes_tl}
Expand Down Expand Up @@ -508,9 +502,9 @@ include hocc
MatterToken {token_}
| sep:Sep ->
let token_ = match sep with
| SepLineDelim {line_delim=token_}
| SepSemi {semi=token_}
| SepBar {bar=token_}
| SepLineDelim {line_delim=LINE_DELIM {token_}}
| SepSemi {semi=SEMI {token_}}
| SepBar {bar=BAR {token_}}
-> token_
in
MatterToken {token_}
Expand Down Expand Up @@ -1210,17 +1204,17 @@ let rec pp_token_hocc (HOCC {token_}) formatter =
| SepLineDelim {line_delim} ->
formatter |> Fmt.fmt "SepLineDelim "
|> fmt_lcurly ~alt ~width
|> Fmt.fmt "line_delim=" |> Scan.Token.pp line_delim
|> Fmt.fmt "line_delim=" |> pp_token_line_delim line_delim
|> fmt_rcurly ~alt ~width
| SepSemi {semi} ->
formatter |> Fmt.fmt "SepSemi "
|> fmt_lcurly ~alt ~width
|> Fmt.fmt "semi=" |> Scan.Token.pp semi
|> Fmt.fmt "semi=" |> pp_token_semi semi
|> fmt_rcurly ~alt ~width
| SepBar {bar} ->
formatter |> Fmt.fmt "SepBar "
|> fmt_lcurly ~alt ~width
|> Fmt.fmt "bar=" |> Scan.Token.pp bar
|> Fmt.fmt "bar=" |> pp_token_bar bar
|> fmt_rcurly ~alt ~width
and pp_sep sep formatter =
fmt_sep sep formatter
Expand Down
Loading

0 comments on commit aa76e02

Please sign in to comment.