Created
December 14, 2014 11:48
-
-
Save pstuifzand/2d13238fbf12c7dadf72 to your computer and use it in GitHub Desktop.
Minecraft NBT bfft (bininspector)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include 'utf8.bfft' | |
struct tag_byte { | |
unsigned 8 big byte; | |
summary 'Byte(', byte, ')'; | |
} | |
struct tag_short { | |
unsigned 16 big short; | |
summary 'Short(', short, ')'; | |
} | |
struct tag_int { | |
unsigned 32 big int; | |
summary 'Int(', int, ')'; | |
} | |
struct tag_long { | |
unsigned 64 big long; | |
summary 'Long(', long, ')'; | |
} | |
struct tag_float { | |
float 32 big float_value; | |
summary 'Float(', float_value, ')'; | |
} | |
struct tag_double { | |
float 64 big double; | |
summary 'Double(', double, ')'; | |
} | |
struct tag_byte_array { | |
unsigned 32 big length; | |
unsigned 8 big bytes[length]; | |
summary 'byte_array(', bytes, ')'; | |
} | |
struct tag_string { | |
unsigned 16 big length; | |
utf8_t string[length]; | |
summary 'tag_string("', str(@string), '")'; | |
} | |
struct tag_list { | |
unsigned 8 big tagid; | |
unsigned 32 big length; | |
enumerate(tagid) { | |
0x00: tag_end end; | |
0x01: tag_byte byte[length]; | |
0x02: tag_short short[length]; | |
0x03: tag_int int[length]; | |
0x04: tag_long long[length]; | |
0x05: tag_float float_value[length]; | |
0x06: tag_double double[length]; | |
0x07: tag_byte_array byte_array[length]; | |
0x08: tag_string string[length]; | |
0x09: tag_list list[length]; | |
0x0A: tag_compound compound[length]; | |
0x0B: tag_int_array int_array[length]; | |
} | |
summary 'list[', length, '] => (', summaryof(tags), ')'; | |
} | |
struct tag_compound { | |
slot done = false; | |
named_tag tags[while: !done]; | |
summary 'compound(', summaryof(tags), ')'; | |
} | |
struct tag_end { | |
signal done = true; | |
} | |
struct named_tag { | |
unsigned 8 big tag_type; | |
if (tag_type != 0) { | |
tag_string name; | |
} | |
enumerate(tag_type) { | |
0x00: tag_end end; | |
0x01: tag_byte byte; | |
0x02: tag_short short; | |
0x03: tag_int int; | |
0x04: tag_long long; | |
0x05: tag_float float_value; | |
0x06: tag_double double; | |
0x07: tag_byte_array byte_array; | |
0x08: tag_string string; | |
0x09: tag_list list; | |
0x0A: tag_compound compound; | |
0x0B: tag_int_array int_array; | |
} | |
summary 'named_tag(', name, ')'; | |
} | |
struct main { | |
named_tag root; | |
assert eof; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment