awesome reply!<br><br><b><i>Colin Brough <Colin.Brough@blueyonder.co.uk></i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> > Hey, I was just wandering whether anyone had any experience making <br>> parsers. I am currently trying to make a PS2 game (using the PS2 Linux <br>> Devkit) and want to start creating config files for various things <br>> (maybe XML, maybe custom layout, yet to be decided) and have tried <br>> looking into writing my own parser function. I can't seem to find <br>> anything anywhere in the form of a guide or tutorial to give me <br>> directions. Everywhere I look says Bison.<br>> I have tried looking for Bison tutorials and come up with very little too.<br>> Does anyone have any experience with Bison or even have any knowledge on <br>> the writing of parsers?<br><br>Bison is a (now superior) clone of yacc, and one of the first pieces<br>of
GNU software Stallman ever released. But you will still find a<br>better set of tutorials googling for yacc than bison (yacc = Yet<br>Another Compiler Compiler).<br><br>You will also find mention of lex to work alongside yacc/bison, and<br>its probably worth understanding the connection between the two.<br><br>Best place to find good reading on this stuff is in an introduction to<br>compilers course text book - the standard text in my day was the<br>Dragon book by Aho, Sethi and Ullman:<br><br> http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886<br><br>A quick look reveals a new edition (2007) by Aho, Lam, Sethi and<br>Ullman - at typical text book price of £50!! Yikes... This will<br>provide the theoretical underpinnings to grammars - see, for a<br>starter, http://en.wikipedia.org/wiki/LALR_parser.<br><br>The grammar is the set of rules that tell you what is a syntactically<br>valid config file and what is not. Given the grammar (the input
file<br>to yacc/bison) and something to convert the raw text of the config<br>file into tokens (lex can do this, though for simple cases its as easy<br>to code it by hand), bison will produce C code that will read your<br>config files. You then embed stuff (C code) into the yacc/bison input<br>file that will "do stuff" when a particular construct is<br>recognised. So at the point in the grammar where something like an<br>assignment of a variable with a value ( "StartLevel = 3", or whatever)<br>is recognised you add code that sets the corresponding variable with<br>the value on the right hand side...<br><br>http://epaperpress.com/lexandyacc/ looks like a reasonable<br>introduction.<br><br>Its been nearly 20 years since I did this stuff in anger, so you'll<br>forgive me for having forgotten the details. The last grammar I wrote<br>was for my honours project in 1989/90, and I'm *still* very upset that<br>at some point along the way I lost the tarball with all the source
and<br>documentation for that!<br><br>HTH<br><br>Cheers<br><br>Colin<br><br>----------------------------------------------------------------------<br>Colin Brough Colin.Brough@blueyonder.co.uk<br><br><br>_______________________________________________<br>dundee GNU/Linux Users Group mailing list<br>dundee@lists.lug.org.uk http://dundee.lug.org.uk<br>https://mailman.lug.org.uk/mailman/listinfo/dundee<br>Chat on IRC, #tlug on dundee.lug.org.uk<br></blockquote><br><p> 
<hr size=1> Sent from <a href="http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=51949/*http://uk.docs.yahoo.com/mail/winter07.html">Yahoo!</a> - a smarter inbox.