Hexit is a dual [[MIT License]]/[[CC0]] licensed binary format description language written in [[Rust]].
- [Source](https://github.com/ogham/hexit)
> Hexit is a tiny programming language that deals with bytes. It’s useful for writing binary formats and network packets without the tedium of forgetting which byte means what, or having to stumble around a hex editor. I like to think of it as “Markdown for binary”.
# Notability
It is really simple domain specific language but that is what makes it neat. I think it is more "literate programming for binary".
Its list of [[#Constants]] is also quite useful for reference.
# Philosophy
Sadly the same fate as [[eza - file listing utility#exa|exa]].
# Platform Support
# Features
It defines a single immutable and non-parametric binary stream.
This might sound useless, but it can be used to literately document fixed preambles or even entire exchanges. Check out the `examples` directory to see it in action.
# Syntax
The readme doesn't really explain much, but it is all there in the source and examples which is pretty reasonable.
## Comments
- Everything *before* the last colon `:` is ignored
- Everything *after* the first hash `#` is ignored
## Literals
- Hex Char - `FF`
- Decimal - `[12345]`
- String - `"foobar"`
- IPv4 - `[127.0.0.1]`
- IPv6 - ``
- Timestamp<sup>*</sup> - `le32[2017-12-31T21:36:45]`
- Float -
- Bits - `[b0101_1010]`
<sup>* requires multibyte function</sup>
## Functions
Usage: `fn(arg)` or `fn[arg]` for decimals
```
be16[512]
x12(AA)
```
### Multibyte
- `be16` - interpret value as 16-bit big endian
- `be32`
- `be64`
- `le16`
- `le32`
- `le64`
- `xN` - repeat `N` times
### Bitwise
- `and` - bitwise and `and(XX YY)`
- `or`
- `xor`
- `not`
## Constants
The [list of constants](https://github.com/ogham/hexit/blob/a2db0b8e17e62d224acb0b3bd241397aa1f2696e/hexit-lang/src/constants.rs) includes types of information such as:
- Gzip compression flags
- ICMP message types
- TCP/IP flags/protocols
- DNS record types
- and more
# References
- https://github.com/ogham/hexit/blob/master/hexit-lang/src/ast.rs