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

3d: allow fields that consume all input #116

Merged
merged 3 commits into from
Dec 1, 2023
Merged

Conversation

tahina-pro
Copy link
Member

This PR allows adding a field at the end of a typedef struct definition to consume the remainder of the input:

typedef struct _test {
   UINT32 my_field;
   UINT8 remainder[:consume-all];
} test;

The remainder field uses the parse_all_bytes parser, which does not have the strong prefix property, so this field must be at the end of the struct.

Similarly, such a field makes its enclosing type test lose the strong prefix property, so the type itself must be used either at the end of a struct, or with a [:byte-size n], [:byte-size-single-element-array n] or [:byte-size-single-element-array-at-most n] container.

@tahina-pro tahina-pro added the 3d The 3d dependent data description language and frontend label Dec 1, 2023
@@ -774,6 +775,7 @@ let mk_prim_t x = with_dummy_range (Type_app (with_dummy_range (to_ident' x)) Ki
let tbool = mk_prim_t "Bool"
let tunit = mk_prim_t "unit"
let tuint8 = mk_prim_t "UINT8"
let tuint8be = mk_prim_t "UINT8BE"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, this is relevant here: I see no reason to reject UINT8BE remainder[:consume-all]

@nikswamy
Copy link
Contributor

nikswamy commented Dec 1, 2023

Looks good to me, thanks! A bit surprised by UINT8BE ... but I guess it's good for uniformity.

@nikswamy nikswamy merged commit 6ce6d3a into master Dec 1, 2023
3 checks passed
@tahina-pro tahina-pro deleted the _taramana_3d_consume_all branch December 1, 2023 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3d The 3d dependent data description language and frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants