Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news.misty.com!news.iecc.com!.POSTED!nerds-end From: Torsten =?UTF-8?B?RWljaHN0w6RkdA==?= Newsgroups: comp.compilers Subject: Re: parsing bibtex file with flex/bison Date: Mon, 25 Mar 2013 13:41:30 +0100 Organization: FernUni Hagen Lines: 30 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-03-016@comp.compilers> References: <13-03-003@comp.compilers> <13-03-004@comp.compilers> <13-03-006@comp.compilers> <13-03-013@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: leila.iecc.com 1364277585 31419 64.57.183.58 (26 Mar 2013 05:59:45 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Tue, 26 Mar 2013 05:59:45 +0000 (UTC) Keywords: parse, practice Posted-Date: 26 Mar 2013 01:59:44 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:877 Rudra Banerjee wrote: > The problem is, how I integrate this two code, i.e. put the $1, $3 of " > KEY '=' VALUE ',' { printf("%s : %s\n",$1, $3); };" in the hash table. RTFM man scanf ??? And for a more complete "real" program you may want to insert error handling in your code, i.e. detect syntax errors and things like file not found etc.. Do I remember right that bison/flex info docs contain good hints how to do that? Or there is a good HOWTO or docs in /usr/share/doc/flex/bison or you search the net (some years past since I wrote a parser w/ flex/bison). From my experience it is good to do so (latest) once you have a working outline (frame), and it looks like you have one. Do not make it too detailed, though, to not fog your "real" code too much. Very likely you can subsume error cases for a simple program. Personally, I like the approach to start writing test cases and then fill in the real code to fulfill the requirements. This helps you to make sure you do not miss s/th and in many cases unveils simple flaws _early_ that we usually insert when programming. I.e. you start w/ a program that fails -- but it tells you why! Then, step by step, your program solves the requirements until you're satisfied (according to the test cases/requirements). E.g. /* very (too) simple implementation */ #ifdef TESTING check( requirement_1 ) #endif -- =|o)