gennyble / hext

A Binary File Markup Language
ISC License
23 stars 0 forks source link

Compilation Hints #4

Closed gennyble closed 3 years ago

gennyble commented 4 years ago

When going form hext to binary, there are some things that are too important to leave as command line flags. Stuff like the bitness (#3) and maybe even, if it's implemented, the checksum location (#2).

Here's how I think it should be done here. Not many hints, and they should be short. Here are all the ones I can think might be needed:

~padding msb
~padding lsb
~padding off
~checksum from 0x00 to 0x10 at 0x20
~checksum from 0x00 to 0x10 replace ZZ

Where ~padding off is the default value.

gennyble commented 3 years ago

There are multiple different kinds of checksum. In TCP alone you have two different types fro IPv4 and IPv6. What is a good syntax to select between them?

~checksum [type] from 0x00 to 0x20 at 0x08

I don't think the replace syntax is necessarily a good idea. Not every check is 16-bits like TCP/IP.

gennyble commented 3 years ago

I've thought about this for far too long, and I've come to a conclusion.

The goal of hext is to define binary files in an easily editable way while also remaining consistent across different machines. So things as important to the file as the bit order should be defined with one of these so-called compilation hints.

gennyble commented 3 years ago

New plan. Here are the headers, required by every hxt file, being implemented:

Every file is required to have a bit ordering identifier and a byte ordering identifier. It'll be at the top of the file, the first line, after a tilda. You may specify them in either order. The valid keywords are: msbyte, lsbyte, msbit, lsbit. They can be used as such:

~msbyte lsbit

The byte ordering is currently only used for multi-byte characters in string literals.

You may then turn padding on and it will use the bit ordering you specified. It MUST appear directly after the header and would look like this:

~pad bits
gennyble commented 3 years ago

Change-Of-New Plan: The head is a single line and may include any properties, but you MUST specify a bit and byte order, and they may ONLY appear ONCE. So this is valid

~lsbit msbye padbits

but this is not:

~lsbit msbyte msbit padbits
gennyble commented 3 years ago

closed in 767b44a