首页 > 解决方案 > What are the parser techniques implemented in kaitai struct? Does it implement backtracking?

问题描述

I have to deal with a buffer of bytes. This buffer can have multiple grammars (A, B, C, .. , etc).

For example: AxxxxBxxxxACxxx

where x's are dirty bytes and I would like to skip them. (They don't match any grammar)

I want to know if it is possible to use kaitai-struct to parse those grammars skipping the dirty bytes.

标签: parsingbacktrackingkaitai-struct

解决方案


No, it's not possible, and it's generally not an objective of Kaitai Struct.

Whole idea of binary parsing is generally very different from classic parsing theory, as binary formats are designed to be machine-readable and thus are typically non-ambiguous. Binary parsers typically are very straightforward and do not employ "state", "backtracking", "recursive descent", grammars as a representation of internal state machine, etc.


推荐阅读