UpstandingHackers / hammer

Parser combinators for binary formats, in C. Yes, in C. What? Don't look at me like that.
GNU General Public License v2.0
430 stars 40 forks source link

add h_permutation #106

Closed pesco closed 10 years ago

pesco commented 10 years ago

please have a look. it differs from

http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=D04D91DBBCDDDF3D364C17C4DAD59606?doi=10.1.1.20.8347&rep=rep1&type=pdf

in that there is no "sublanguage" for describing permutation parsers. you can use your regular HParsers as arguments to h_permutation. optional elements work with h_optional as one would intuitively expect. what is not supported in the same way, in relation to the above paper, are optional elements with default values. you can have a parser that is a choice with a default branch of course, but the difference is that it might be tried too early, depending on its place in the argument list, and default even though it could match later. so to get the same result, one would have to use plain optionals and replace the TT_NONE results with default values after the fact.