On Sep 24, 2006, at 12:20 PM, Adam R. Maxwell wrote:
Well, I happen to think that parsing BibTeX is fairly difficult to do correctly. As a trivial example,
@article(citekey, title = "title", author = "m{"e} and myself")
and
@article{citekey, title = {title}, author = {me{"e} and myself}}
are both valid BibTeX (note the use of () and "" instead of {} pairs). Add whitespace and remove newlines for extra fun. You can write an ad-hoc parser that's probably adequate for completion (although even then I can imagine some difficulty with encodings).
Do I understand correctly though, that if the bib file is saved from within BibDesk, then it has kind of a standardized format, that would avoid both of the above cases?
My parser is certainly extremely weak, and it assumes that the bibfile is pretty well formatted, which is the case with my bib files. They are however very small. I agree it would be extremely difficult to write a parser that actually parses the entire bib file to recover all the information. To begin with, I haven't even been able to find a complete and clear reference for the BibTeX syntax.
For me the main/only disadvantage of the bibdesk completion command is that it needs BibDesk to be running, with the current file open and up front, unless I'm mistaken. It's been a while since I've used it.
Haris
PS: BibDesk is an awesome program, I can't even imagine managing bib files without it.