Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My fork - Sprache Binary parser #193

Open
Serabass opened this issue Dec 27, 2023 · 0 comments
Open

My fork - Sprache Binary parser #193

Serabass opened this issue Dec 27, 2023 · 0 comments

Comments

@Serabass
Copy link

Serabass commented Dec 27, 2023

Hello, I forked this repo and developing another project with it's concept.

https://github.com/Serabass/Sprache-binary

This project works in a similar way but does a different job - It helps to parse binary structures.
A simple example here:

struct RGB {
   byte R;
   byte G;
   byte B;
}

I can write a parser with Sprache's concept:

var parser = 
    from r in Parse.AnyByte
    from g in Parse.AnyByte
    from b in Parse.AnyByte
    select new RGB { R = r, G = g, B = b };

var memoryStream = new MemoryStream(new byte[] { 255, 0, 0 });
var rgb = parser.Parse(memoryStream);

Assert.Equal(255, rgb.R);
Assert.Equal(0, rgb.G);
Assert.Equal(0, rgb.B);

(I wrote a list of simple binary primitive types)

I'm using the reading of Stream instead of String input.

I'll be glad if you help me in development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant