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

enhancement: conditional field / algebaric data type / tagged union #17

Closed
farteryhr opened this issue Dec 4, 2020 · 2 comments
Closed

Comments

@farteryhr
Copy link

something like a field in a struct with predicates about previous variable.

enum TypeTag : u8{
    U32 = 1,
    ARRAY = 2
}
struct Variable {
    TypeTag tag;
    u32 u32Value if tag==TypeTag.U32;
    u32 length if tag==TypeTag.ARRAY;
    Variable elements[length] if tag==TypeTag.ARRAY; // or pointer to array
}

that may help parsing of byte streams with a bit more complex structures with branching (like some simplified version of MessagePack, Protocol Buffer...) (but they're more complicated, e.g. the type tag is in bitfield, and needs more advanced way to spedcify how to parse a variable int, etc.)

@Kein
Copy link

Kein commented Dec 4, 2020

Yep, that would be useful, 0Editor has similar stuff in his conditional parser

@WerWolv
Copy link
Owner

WerWolv commented Jan 6, 2021

As of the latest commit, ImHex supports control flow statements using the if and else keywords. I hope this will make the language a lot more useful for you :)

On the picture, only single line statements are shown, however it's possible to enclose more than one statement under one if using curly brackets as you would in any other C-like language

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants