Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support empty bitfield #902

Open
wants to merge 1 commit into
base: sail2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions test/lem/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'bitfield_exponential',
'bitfield_abs',
'bitfield_mod',
'bitfield_empty',
# Abstract types not implemented for Lem yet
'abstract_bool',
'abstract_bool2',
Expand Down
7 changes: 7 additions & 0 deletions test/typecheck/pass/bitfield_empty.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default Order dec

$include <prelude.sail>

type xlen : Int = 2 ^ 2

bitfield foo : bits(xlen) = { }
Loading