I have a file specification in BNF format. How do I implement a parser that can read those files?
Posted on 2010-09-01
I have a specification for a proprietary text-based file format. The spec contains about 10 pages worth of BNF logic to describe the formatting rules for these files. I would like to implement a program that can read files in this format. My understanding is that I'll need some kind of tool set (like lex and yacc) to parse and validate the file, and then read the contents of the file to allocate and populate objects in my program.
There are commercial implementations of this spec, but the vendors that I have found charge *annual* licensing fees in the tens of thousands of dollars. To my knowledge, the organization that devised the spec charges no such royalty fees--it sounds like the cost is just an issue of the vendors' business models, and the fact that we're a niche industry.
When we look at what we need to do with the files vs. how much the 3rd party licenses cost, the build vs. buy equation makes it seem much more practical to roll our own implementation.
Getting back to the BNF issue, I *vaguely* remember dealing with this in my compilers class in college, but that was several years ago, and I haven't used that stuff since that class. Should I look into a tool set like lex and yacc? Or are there other options available? I'm open to a variety of options (C++, .NET, etc).