Skip to content

Commit

Permalink
Add binding error tests (currently failing)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Evans committed Aug 23, 2024
1 parent 0505b95 commit e37f40b
Show file tree
Hide file tree
Showing 9 changed files with 2,448 additions and 1,446 deletions.
17 changes: 10 additions & 7 deletions bootstrap/bin/hocc/Parse.hmh
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ type nonterm_precs_tl =
| PatternFieldPattern of {pattern: nonterm_pattern}
and nonterm_pattern_fields =
| PatternFieldsOne of {pattern_field: nonterm_pattern_field}
| PatternFieldsMulti of {pattern_field_a: nonterm_pattern_field;
pattern_field_b: nonterm_pattern_field}
| PatternFieldsMulti of {pattern_field: nonterm_pattern_field;
pattern_fields: nonterm_pattern_fields}
and nonterm_semi_suffix =
| SemiSuffix
and nonterm_module_path =
Expand Down Expand Up @@ -462,8 +462,8 @@ include hocc
| pattern_field:PatternField
| pattern_field:PatternField ";" "_"
-> PatternFieldsOne {pattern_field}
| pattern_field_a:PatternField ";" pattern_field_b:PatternField
-> PatternFieldsMulti {pattern_field_a; pattern_field_b}
| pattern_field:PatternField ";" pattern_fields:PatternFields
-> PatternFieldsMulti {pattern_field=pattern_field; pattern_fields}

nonterm SemiSuffix of nonterm_semi_suffix ::=
| ";"
Expand Down Expand Up @@ -499,8 +499,11 @@ include hocc
| binding:Binding ":" prod_param_symbol:ProdParamSymbol
-> ProdParamBinding {binding; prod_param_symbol}
| lparen:"(" pattern:Pattern rparen:")" ":" prod_param_symbol:ProdParamSymbol
| ModulePath "." lparen:"(" pattern:Pattern rparen:")" ":" prod_param_symbol:ProdParamSymbol
-> ProdParamPattern {lparen; pattern; rparen; prod_param_symbol}
| lcurly:"{" fields:PatternFields SemiSuffix rcurly:"}" ":" prod_param_symbol:ProdParamSymbol
| ModulePath "." lcurly:"{" fields:PatternFields SemiSuffix rcurly:"}" ":"
prod_param_symbol:ProdParamSymbol
-> ProdParamFields {lcurly; fields; rcurly; prod_param_symbol}
| "_" ":" prod_param_symbol:ProdParamSymbol
| prod_param_symbol:ProdParamSymbol
Expand Down Expand Up @@ -1446,12 +1449,12 @@ let rec pp_token_hocc (HOCC {token_}) formatter =
|> fmt_lcurly ~alt ~width
|> Fmt.fmt "pattern_field=" |> fmt_pattern_field ~alt ~width:width' pattern_field
|> fmt_rcurly ~alt ~width
| PatternFieldsMulti {pattern_field_a; pattern_field_b} ->
| PatternFieldsMulti {pattern_field; pattern_fields} ->
formatter |> Fmt.fmt "PatternFieldsMulti "
|> fmt_lcurly ~alt ~width
|> Fmt.fmt "pattern_field_a=" |> fmt_pattern_field ~alt ~width:width' pattern_field_a
|> Fmt.fmt "pattern_field=" |> fmt_pattern_field ~alt ~width:width' pattern_field
|> fmt_semi ~alt ~width
|> Fmt.fmt "pattern_field_b=" |> fmt_pattern_field ~alt ~width:width' pattern_field_b
|> Fmt.fmt "pattern_fields=" |> fmt_pattern_fields ~alt ~width:width' pattern_fields
|> fmt_rcurly ~alt ~width
and pp_pattern_fields pattern_fields formatter =
fmt_pattern_fields pattern_fields formatter
Expand Down
3,811 changes: 2,374 additions & 1,437 deletions bootstrap/bin/hocc/Parse.ml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bootstrap/bin/hocc/spec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ let symbols_init io precs symbols hmh =
in
io
end
| ProdParamPattern _ -> not_implemented "XXX"
| ProdParamFields _ -> not_implemented "XXX"
| ProdParamPattern _ -> not_implemented "XXX spec ProdParamPattern"
| ProdParamFields _ -> not_implemented "XXX spec ProdParamFields"
| ProdParam _ -> io
in
let param =
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions bootstrap/test/hocc/Binding_error_b.hmh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type t: t = {
x: uns
y: uns
}

hocc
token T of t
token EOI
start S of uns ::=
| {x; y}:T EOI -> x + y
| {x; y=x}:T EOI -> x + y
Empty file.
11 changes: 11 additions & 0 deletions bootstrap/test/hocc/Binding_error_c.hmh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type t: t = {
x: uns
y: uns
}

hocc
token T of t
token EOI
start S of uns ::=
| {x; _}:T EOI
| {x; y}:T EOI -> x + y
16 changes: 16 additions & 0 deletions bootstrap/test/hocc/Parse_a.hmh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ include hocc
nonterm N7 of Unit.t ::=
| OP n:N1 _:N2 -> foo

start N8 of Unit.t ::=
|
_:N5
x0:N5
{x2}:N5
X.{x2}:N5
{x3; x4}:N6
(_):N5
(x5):N5
X.(x5):N5
(X x6):N5
(X.(x7)):N5
(x8, x9):N5
{x10; x11=x12; x13={x14; _}; _;}:N5
-> ()

Code = {
}

Expand Down
24 changes: 24 additions & 0 deletions bootstrap/test/hocc/dune
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,30 @@
(alias runtest)
(action (diff Binding_error.expected Binding_error.out)))

(rule
(deps
(glob_files Binding_error_b.hmh*)
%{bin:hocc})
(action
(with-accepted-exit-codes
(or 0 1)
(with-outputs-to Binding_error_b.out (run ./hocc_test %{bin:hocc} Binding_error_b -v)))))
(rule
(alias runtest)
(action (diff Binding_error_b.expected Binding_error_b.out)))

(rule
(deps
(glob_files Binding_error_c.hmh*)
%{bin:hocc})
(action
(with-accepted-exit-codes
(or 0 1)
(with-outputs-to Binding_error_c.out (run ./hocc_test %{bin:hocc} Binding_error_c -v)))))
(rule
(alias runtest)
(action (diff Binding_error_c.expected Binding_error_c.out)))

(rule
(deps
(glob_files Unused.hmh*)
Expand Down

0 comments on commit e37f40b

Please sign in to comment.