Computer Chess Club Archives


Search

Terms

Messages

Subject: Writting a PGN parser. Need advices.

Author: Mathieu Pagé

Date: 10:05:27 06/21/05


Hi,

 I plan to write a PGN parser for my engine. Since PGN is well defined, but
really hard to parse, I plan to write it in such a way that it can be used by
anyone who do not want to write one for their engine.

 I am currently wondering what should my public interface look like. I currently
have two options :

1 - OO interface (DOM like)
 A collections of class used to parse and write PGN in a OO way (mean I will
write it in C++). Those collections should include : PgnGamesCollection,
PgnGame, PgnTag, PgnMove, PgnVariation, PgnComment, PgnNAG, etc.

2 - Event driven parser (SAX like, i think)
 Using pointer to functions I could create an event driven parser. Before
initializing the parsing process the caller code would have to register some
envent handler like those : BeginParsing(), BeginGame(), ParsingTag(),
ParsingMove(), ParsingComment(), EnteringVariation(), QuittingVariation(), etc.

 I personnaly prefer the second options since it would be easier to integrate in
others engines and can be written in C. Also I could write an "OO type parser"
over the "Event driven Parser" (I think that's the way XML DOM parser are
implemented).

 I'd like to know if such a parser would interest some of the engines programmer
here. I'm I going to have users ?

 Any advice on how I should format the public interface or how the mechanic of
such a parser should work would be more than appreciated.

Mathieu Pagé

PS.: Sorry for my poor english I really try to make myself clear, but sometimes
I feel i'm not.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.