Skip to content

Commit

Permalink
Simplify SymbolType0 (was OfSymbolType0)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Evans committed Aug 21, 2024
1 parent 0439724 commit bee975a
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 157 deletions.
48 changes: 24 additions & 24 deletions bootstrap/bin/hocc/Parse.hmh
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ type nonterm_ident =
and nonterm_symbol_type =
| SymbolType of {symbol_type_qualifier: nonterm_symbol_type_qualifier;
symbol_type: token_uident}
and nonterm_of_symbol_type0 =
| OfSymbolType0SymbolType of {symbol_type: nonterm_symbol_type}
| OfSymbolType0Epsilon
and nonterm_symbol_type0 =
| SymbolType0SymbolType of {symbol_type: nonterm_symbol_type}
| SymbolType0Epsilon
and nonterm_prec_ref =
| PrecRefUident of {uident: token_uident}
| PrecRefEpsilon
Expand All @@ -164,7 +164,7 @@ type nonterm_ident =
| TokenAliasEpsilon
and nonterm_token =
| Token of {token_: Scan.Token.t; cident: token_cident; token_alias: nonterm_token_alias;
of_symbol_type0: nonterm_of_symbol_type0; prec_ref: nonterm_prec_ref}
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}
Expand Down Expand Up @@ -342,9 +342,9 @@ include hocc
| "of" symbol_type_qualifier:SymbolTypeQualifier symbol_type:UIDENT ->
SymbolType {symbol_type_qualifier; symbol_type}

nonterm OfSymbolType0 of nonterm_of_symbol_type0 ::=
| symbol_type:SymbolType -> OfSymbolType0SymbolType {symbol_type}
| epsilon -> OfSymbolType0Epsilon
nonterm SymbolType0 of nonterm_symbol_type0 ::=
| symbol_type:SymbolType -> SymbolType0SymbolType {symbol_type}
| epsilon -> SymbolType0Epsilon

nonterm PrecRef of nonterm_prec_ref ::=
| "prec" uident:UIDENT -> PrecRefUident {uident}
Expand All @@ -355,10 +355,10 @@ include hocc
| epsilon -> TokenAliasEpsilon

nonterm Token of nonterm_token ::=
| token_:"token" cident:CIDENT token_alias:TokenAlias of_symbol_type0:OfSymbolType0
| token_:"token" cident:CIDENT token_alias:TokenAlias symbol_type0:SymbolType0
prec_ref:PrecRef ->
let TOKEN {token_} = token_ in
Token {token_; cident; token_alias; of_symbol_type0; prec_ref}
Token {token_; cident; token_alias; symbol_type0; prec_ref}

nonterm Sep of nonterm_sep ::=
| line_delim:LINE_DELIM ->
Expand Down Expand Up @@ -1187,19 +1187,19 @@ let rec pp_token_hocc (HOCC {token_}) formatter =
and pp_symbol_type symbol_type formatter =
fmt_symbol_type symbol_type formatter

and fmt_of_symbol_type0 ?(alt=Fmt.alt_default) ?(width=Fmt.width_default) of_symbol_type0
and fmt_symbol_type0 ?(alt=Fmt.alt_default) ?(width=Fmt.width_default) symbol_type0
formatter =
let width' = width + 4L in
match of_symbol_type0 with
| OfSymbolType0SymbolType {symbol_type} ->
formatter |> Fmt.fmt "OfSymbolType0SymbolType "
match symbol_type0 with
| SymbolType0SymbolType {symbol_type} ->
formatter |> Fmt.fmt "SymbolType0SymbolType "
|> fmt_lcurly ~alt ~width
|> Fmt.fmt "symbol_type=" |> fmt_symbol_type ~alt ~width:width' symbol_type
|> fmt_rcurly ~alt ~width
| OfSymbolType0Epsilon ->
formatter |> Fmt.fmt "OfSymbolType0Epsilon"
and pp_of_symbol_type0 of_symbol_type0 formatter =
fmt_of_symbol_type0 of_symbol_type0 formatter
| SymbolType0Epsilon ->
formatter |> Fmt.fmt "SymbolType0Epsilon"
and pp_symbol_type0 symbol_type0 formatter =
fmt_symbol_type0 symbol_type0 formatter

and fmt_prec_ref ?(alt=Fmt.alt_default) ?(width=Fmt.width_default) prec_ref formatter =
match prec_ref with
Expand Down Expand Up @@ -1228,7 +1228,7 @@ let rec pp_token_hocc (HOCC {token_}) formatter =
and fmt_token ?(alt=Fmt.alt_default) ?(width=Fmt.width_default) token_ formatter =
let width' = width + 4L in
match token_ with
| Token {token_; cident; token_alias; of_symbol_type0; prec_ref} ->
| Token {token_; cident; token_alias; symbol_type0; prec_ref} ->
formatter |> Fmt.fmt "Token "
|> fmt_lcurly ~alt ~width
|> Fmt.fmt "token_=" |> Scan.Token.pp token_
Expand All @@ -1237,7 +1237,7 @@ let rec pp_token_hocc (HOCC {token_}) formatter =
|> fmt_semi ~alt ~width
|> Fmt.fmt "token_alias=" |> fmt_token_alias ~alt ~width:width' token_alias
|> fmt_semi ~alt ~width
|> Fmt.fmt "of_symbol_type0=" |> fmt_of_symbol_type0 ~alt ~width:width' of_symbol_type0
|> Fmt.fmt "symbol_type0=" |> fmt_symbol_type0 ~alt ~width:width' symbol_type0
|> fmt_semi ~alt ~width
|> Fmt.fmt "prec_ref=" |> fmt_prec_ref ~alt ~width:width' prec_ref
|> fmt_rcurly ~alt ~width
Expand Down Expand Up @@ -1848,9 +1848,9 @@ let postlude_base_of_hocc (Hocc {stmts=Stmts {stmt; stmts_tl}; _}) =
| PrecRelsEpsilon -> None
and of_symbol_type = function
| SymbolType {symbol_type=UIDENT {token_}; _} -> token_
and of_of_symbol_type0 = function
| OfSymbolType0SymbolType {symbol_type} -> Some (of_symbol_type symbol_type)
| OfSymbolType0Epsilon -> None
and of_symbol_type0 = function
| SymbolType0SymbolType {symbol_type} -> Some (of_symbol_type symbol_type)
| SymbolType0Epsilon -> None
and of_prec_ref = function
| PrecRefUident {uident=UIDENT {token_}} -> Some token_
| PrecRefEpsilon -> None
Expand Down Expand Up @@ -1915,10 +1915,10 @@ let postlude_base_of_hocc (Hocc {stmts=Stmts {stmt; stmts_tl}; _}) =
of_prec_rels prec_rels
|> Option.value_or_thunk ~f:(fun () -> uident)
end
| StmtToken {token_=Token {cident=CIDENT {token_=cident}; token_alias; of_symbol_type0;
| StmtToken {token_=Token {cident=CIDENT {token_=cident}; token_alias; symbol_type0;
prec_ref; _}} -> begin
of_prec_ref prec_ref
|> Option.some_or_thunk ~f:(fun () -> of_of_symbol_type0 of_symbol_type0)
|> Option.some_or_thunk ~f:(fun () -> of_symbol_type0 symbol_type0)
|> Option.some_or_thunk ~f:(fun () -> of_token_alias token_alias)
|> Option.value_or_thunk ~f:(fun () -> cident)
end
Expand Down
Loading

0 comments on commit bee975a

Please sign in to comment.