synalysis / Grammars

Grammars for Synalyze It! and Hexinator
MIT License
91 stars 14 forks source link

Are these grammars valid? #6

Open KOLANICH opened 5 years ago

KOLANICH commented 5 years ago

When developing synalysis2kaitai I have encountered several anomalies in the grammars in this repo. Are these grammars valid? If they are, how should I treat them?

synalysis commented 5 years ago

Hi, the grammars are valid however you brought up some details that could be improved in the grammar. In the first case the first binary element consumes the rest of the structure because it has no length. So the 2nd binary element is omitted (because it has no minimum length).

In the second case the element is empty and thus useless.

In the 3rd case: is what you consider problematic that the structures contain no elements?

Referencing a structure that doesn't exist is indeed a bug in the grammar.

KOLANICH commented 5 years ago

Thank you for the answers.

In the first case the first binary element consumes the rest of the structure because it has no length. So the 2nd binary element is omitted (because it has no minimum length).

Understood. BTW, should they be without length taking in account https://github.com/synalysis/Grammars/blob/edcba05e98cb7c0019b381aaa2884259a5f655f4/glb.grammar#L18 and https://github.com/synalysis/Grammars/blob/edcba05e98cb7c0019b381aaa2884259a5f655f4/glb.grammar#L30

In the second case the element is empty and thus useless.

How should I treat it? Should I just ignore it?

In the 3rd case: is what you consider problematic that the structures contain no elements?

Not very problematic (I can write some code to deal with it), but just pretty strange (I see no reasons to have such constructions, and I don't know how I should process them correctly).