{"id":171,"date":"2005-12-30T20:09:28","date_gmt":"2005-12-31T04:09:28","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=171"},"modified":"2005-12-30T22:52:10","modified_gmt":"2005-12-31T06:52:10","slug":"parsing-graf-scripts","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/parsing-graf-scripts\/","title":{"rendered":"Parsing GRAF Scripts"},"content":{"rendered":"<p>I missed out on any kind of compiler theory course during my time in academia. Add that to the list of topics I would like to study and comprehend someday (along with 3D graphics and artificial intelligence). <\/p>\n<p>The <a href=\"http:\/\/multiex.xentax.com\/\">MultiEx Commander<\/a> program uses a simple, custom scripting language to interpret game resource archive formats (a.k.a. GRAFs). Why do I care? Because these GRAF files often carry lots of FMV files that I want to separate and study invidually. This is a script that takes apart the BIFF (.bif) GRAF files from <em><a href=\"http:\/\/www.mobygames.com\/game\/windows\/baldurs-gate\">Baldur&#8217;s Gate<\/a><\/em>:<\/p>\n<pre>\r\nIDString 0 BIFFV1 ;\r\nGet DUMMYL Int 0 ;\r\nSavePos FILESTART 0 ;\r\nGet FILECNTL Long 0 ;\r\nMath FILESTART += 16 ;\r\nDo ;\r\nGoTo FILESTART 0 ;\r\nGet FILEOFF Long 0 ;\r\nGet FILESIZE Long 0 ;\r\nMath FILESTART += 16 ;\r\nLog FILENAME FILEOFF FILESIZE 0 0 ;\r\nMath EXTRCNT += 1 ;\r\nWhile EXTRCNT <> FILECNTL ;\r\n<\/pre>\n<p>That script was taken from the <a href=\"http:\/\/wiki.xentax.com\/index.php\/Baldurs_Gate_BIF\">XentaxWiki entry for BIF<\/a>. Plenty more sample scripts are available on that Wiki.<\/p>\n<p>Who can tell me the best approach to writing a program that can interpret scripts like the one shown above? Something tells me that full-fledged compiler theory is overkill for this type of application. It looks like the language was designed to be parsed in a fairly braindead virtual machine. But that&#8217;s just my best, uneducated guess.<\/p>\n<blockquote><p>\n<em>Update:<\/em> I am working on a <a href=\"http:\/\/wiki.xentax.com\/index.php\/BMS\">BMS language spec in the XentaxWiki<\/a>.\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>How would you write a program parser?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-general"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=171"}],"version-history":[{"count":0,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/171\/revisions"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}