# How to define syntax for a binary language

**URL:** https://d.strumenta.community/t/how-to-define-syntax-for-a-binary-language/1273
**Category:** Domain Specific Languages
**Created:** [May 26, 2021, 8:00am UTC](https://d.strumenta.community/t/how-to-define-syntax-for-a-binary-language/1273 "2021-05-26T08:00:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mpostol](https://d.strumenta.community/user_avatar/d.strumenta.community/mpostol/32/666_2.png) [@mpostol](https://d.strumenta.community/u/mpostol)
#### Post date: [May 26, 2021, 8:00am UTC](https://d.strumenta.community/t/how-to-define-syntax-for-a-binary-language/1273/1 "2021-05-26T08:00:28Z")

</div>

Do you know a metalanguage that can be used to define a binary language? The binary language - it means that the alphabet is binary - contains only two characters. Usually, we use metalanguages (e.g. BNF, EBNF, ABNF) to define a new language based on the alphanumeric alphabet. Characters from this alphabet are represented as bitstreams in compliance with a selected encoding, i.e. ASCII, UTF-8. As the result, the same text could be represented by different bitstreams.

The problem I must face up is that sometimes the encoding is undefined, therefore we cannot use the mentioned metalanguages to describe bitstreams syntax.

ABNF contains some features that may be applied to relax the problem but I am not sure if this approach is the only possible.

An example you can find at [NetworkMessage.abnf](https://github.com/mpostol/OPC-UA-OOI/blob/master/Networking/SemanticData/MessageHandling/NetworkMessage.abnf)

Any advice is welcome.

Mariusz

---

<div class="post-metadata">

### Author: ![jurgen.vinju](https://d.strumenta.community/user_avatar/d.strumenta.community/jurgen.vinju/32/20_2.png) [@jurgen.vinju](https://d.strumenta.community/u/jurgen.vinju)
#### Post date: [May 27, 2021, 7:24am UTC](https://d.strumenta.community/t/how-to-define-syntax-for-a-binary-language/1273/2 "2021-05-27T07:24:51Z")

</div>

“Bird” is a DSL for defining binary formats. It is open-source but was developed in a commercial context. It can generate parsers but also anonimizers. [GitHub - SWAT-engineering/bird](https://github.com/SWAT-engineering/bird)
