Skip to content

Commit

Permalink
Fix formatting of bitfields with literal fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Oct 5, 2023
1 parent 87e9a06 commit b6aa716
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions corpus/bitfield.spicy
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ type X = unit {
b: 0..8; # bar
};
};

type X = bitfield(8) {
a: 0..3=2;
b: 4..7;
c: 7 = 1;
};
6 changes: 6 additions & 0 deletions corpus/bitfield.spicy.expected
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ type X = unit {
b: 0..8; # bar
};
};

type X = bitfield(8) {
a: 0..3 = 2;
b: 4..7;
c: 7 = 1;
};
10 changes: 9 additions & 1 deletion src/query.scm
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,22 @@
(sink)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Bitfields.

(
"bitfield"
(_)
"{" @prepend_space
)

; All bitfield fields go on a new line.
(bitfield
(bitfield_field) @prepend_hardline
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Preprocessor macros
; Preprocessor macros.

; Empty lines before preprocessor blocks are fine.
(preproc) @allow_blank_line_before
Expand Down

0 comments on commit b6aa716

Please sign in to comment.