Can I use OhmJS to parse binary values? #491
nileshtrivedi
started this conversation in
General
Replies: 2 comments
-
Yes, Ohm is designed for textual languages. You're right that in general, PEGs could be applied to binary data. But to do something like you're describing here, the parser would need to track the position in the input stream at the level of bits, which Ohm doesn't do. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I remember the precursor to Ohm could do binary data, though it was harder to use and didn't have all of Ohm's niceties. I'd love to see another tool like that one. OMeta, I think it was called.
Josh Marinacci
Recovering Eng
Sent via Superhuman ( ***@***.*** )
…On Thu, Sep 12, 2024 at 1:14 AM, Patrick Dubroy < ***@***.*** > wrote:
Yes, Ohm is designed for textual languages.
You're right that in general, PEGs could be applied to binary data. But to
do something like you're describing here, the parser would need to track
the position in the input stream at the level of bits, which Ohm doesn't
do.
—
Reply to this email directly, view it on GitHub (
#491 (comment) ) ,
or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AACDTSR7ZTALQPYQAMUDGHTZWFENPAVCNFSM6AAAAABN4AZ6ICVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANRSGMZTCNA
).
You are receiving this because you are subscribed to this thread. Message
ID: <ohmjs/ohm/repo-discussions/491/comments/10623314 @ github. com>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It seems like OhmJS seems to be designed to parse textual (ascii or UTF-8) languages. But surely, PEG should be able to handle raw binary values too? So is this just a limitation of OhmJS then?
For example, if I want to parse 32-bit IPv4 addresses:
The string
10111001101110011011100110111001
would be parsed successfully but the actual 4-byte value would not.How do I go about using OhmJS for parsing binary protocols?
Beta Was this translation helpful? Give feedback.
All reactions