News for hackers. Stuff that matters.

Show HN: Resrap – A Parser but in Reverse

https://resrap.osdc.dev/

I built Resrap, a Go package that takes a grammar in ABNF format and generates infinitely long sequences of syntactically correct code...either completely randomly or with seeds for a deterministic generation.

ABNF is a modified version of EBNF(https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_f...) I made for this project, basically means you can specify when generating code 20% of lines will be if{} blocks and 50% will be while{} blocks which allows for more natural code generation, plus support for infinite generation of code.

It’s very fast...it generated ~40 million tokens of C syntax in about 26 seconds on my laptop and supports multithreading which actually saw boosts in performance since its very easy to parallelize.

I originally made this for a typing-test project (I didn’t want to store code snippets manually), but it turned out to be useful in other contexts too, like: - Stress-testing parsers and linters - Creating non-copyrighted “lorem ipsum” code for tech demos - Generating those endless “hacker” code scenes you see in movies

Curious what other cool things people might do with it!

Github: https://github.com/osdc/Resrap Website: https://resrap.osdc.dev/

( 4 comments | 4 points | on HN )
Re:Show HN: Resrap – A Parser but in Reverse by jimmydin7 on Monday September 29, 2025 @02:55PM (#45417395)
wait this seems pretty cool! I like the blue-dark ui and animated texxt
Re:Show HN: Resrap – A Parser but in Reverse by itsarnavsh on Monday September 29, 2025 @02:56PM (#45417412)
Thankss man really appreciate that I wanted to show the package in action so though no better way than this
Re:Show HN: Resrap – A Parser but in Reverse by jimmydin7 on Monday September 29, 2025 @03:24PM (#45417707)
i never understood go, however I made a custom programming lang in python
Re:Show HN: Resrap – A Parser but in Reverse by itsarnavsh on Monday September 29, 2025 @03:27PM (#45417732)
Oh that's cool can you tell me more about that? Also you should give golang a shot it's pretty good generally