Skip to content

Commit

Permalink
Support empty bitfield
Browse files Browse the repository at this point in the history
  • Loading branch information
trdthg committed Jan 22, 2025
1 parent f8de74b commit f1fedff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,12 @@ r_def_body:
| r_id_def Comma r_def_body
{ $1 :: $3 }

bitfield_def_body:
| Lcurly Rcurly
{ [] }
| Lcurly r_def_body Rcurly
{ $2 }

param_kopt:
| kid Colon kind
{ KOpt_aux (KOpt_kind (None, [$1], Some $3, None), loc $startpos $endpos) }
Expand Down Expand Up @@ -1017,8 +1023,8 @@ type_def:
{ mk_td (TD_variant ($2, TypQ_aux (TypQ_tq [], loc $endpos($2) $startpos($3)), $5)) $startpos $endpos }
| Union id typaram Eq Lcurly type_unions Rcurly
{ mk_td (TD_variant ($2, $3, $6)) $startpos $endpos }
| Bitfield id Colon typ Eq Lcurly r_def_body Rcurly
{ mk_td (TD_bitfield ($2, $4, $7)) $startpos $endpos }
| Bitfield id Colon typ Eq bitfield_def_body
{ mk_td (TD_bitfield ($2, $4, $6)) $startpos $endpos }

enum_functions:
| id MinusGt typ Comma enum_functions
Expand Down
11 changes: 11 additions & 0 deletions test/typecheck/pass/bitfield_empty.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
default Order dec

$include <prelude.sail>

type xlen : Int = 2 ^ 2

bitfield foo : bits(xlen) = { }

bitfield bar : bits(xlen) = {

}

0 comments on commit f1fedff

Please sign in to comment.