Related articles |
---|
Embeddable Parser for binary data? stidolph@leland.Stanford.EDU (1994-03-25) |
Re: Embeddable Parser for binary data? ph@anweald.exnet.co.uk (Patrick Herring) (1994-03-26) |
Newsgroups: | comp.compilers |
From: | Patrick Herring <ph@anweald.exnet.co.uk> |
Keywords: | parse, prolog |
Organization: | Anweald Systems |
References: | 94-03-142 |
Date: | Sat, 26 Mar 1994 10:53:04 GMT |
Wayne.Stidolph@mtv.gtegsc.com writes:
>I'm tasked to build a browser of binary data: the data (bus dumps) is
>to be shown to human users in meaningful forms.
...
>I propose the program read in the data block, read some headers in the
>data, and then decide which "format file" is appropriate. The program
>would then read in the "format file" and convert the data into strings
>for presentation. In essence, I need an interpreter where the "format
>file" is the program being interpreted, acting on the data block.
Many Prolog implementations have a DCG notation built in. (DCG = BNF +
arguments). You can write a useable parser/actioner in that, and Prolog
will let you assert (& retract) new grammar rules at run-time. It'll
probably be a tad sluggish mind ...
Alternatively use the parse command in Rexx (which comes with OS/2). This
can match patterns on a left-to-right basis, putting strings into
variables etc eg
Block = '303132003334353600'x
Format = "Prefix '00'x Body '00'x"
interpret 'parse var Block' Format
say 'P' Prefix 'B' Body /* gives P 012 B 3456 */
If you've structures like matching brackets you'll have to do something
fancy.
Use Watcom's VX-Rexx (aka VisualRexx) and you don't even have to touch C -
not sure whether VX-Rexx covers your graphics requirements but I think
there's a C API.
Yours, Patrick
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.