On Tuesday, March 25, 2008, at 04:45AM, "Robin Houston" robin.houston@gmail.com wrote:
On 25/03/2008, Charilaos Skiadas cskiadas@gmail.com wrote:
I don't think it is an easy task at all actually. I could not find a specification for the BibTeX syntax when I was looking into it.
That's okay. I prefer difficult tasks to easy ones. :-)
Lack of a formal spec is no problem. The bibtex source code is very clear, and as long as we use the same parsing logic as bibtex itself, the parser is guaranteed to be 100% compatible.
Right, the formal specification is in the WEB source for BibTeX itself. There are some subtleties in the grammar that I'm sure you'll have fun with.
Haris made a comment about convincing the BibDesk guys to share their parser: I believe I've mentioned before on this list that BibDesk uses Greg Ward's libbtparse; its documentation and grammar are worth investigating if you really want to write your own. Nelson Beebe's TUGBoat article on bibclean is also quite helpful, since he documents various problems that he discovered while writing bibclean. An alternative, of course, is just to use BibDesk's DO connection after it's handled the full parse and cached all the results...but I find that reinventing the wheel is most of the fun of software development :).