🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Parser for plaintext files.

Started by
1 comment, last by rexizt 20 years, 6 months ago
I need some help on designing a parser for some plaintext files. We are building a game engine for an RTS game, and we have decided to store all units, structures, skills and upgrades in plaintext files (along with sound shader, materials and particle systems). I''ve included a sample on a flame unit here. How would I approach the task of writing a parser for these files? I''ve got classes that''s ready for the input. The rest of the files are structured in a similar fassion. flame_unit { base base_soldier_unit speed 10 sight 15 strenght 40 weight 75 hitpoints 250 armor 100 damagepoints 100 projectile flame_soldier_projectile soundshader sound_soldier_flame1 upgrades { armor_medium aim_laser } skills { skill_healer skill_mechanic } }
"may the source be with you"
Advertisement
I would take a look at Lex and Yacc (or their GNU ports Flex and Bison). Alternatively you might be able to use Spirit (which is part of boost). I hear ANTLR is pretty easy to use, but haven''t tried it my self.
Have a look at TinyXML and use an XML file for your definitions.

<unit type="flame" base="base_soldier_unit"><property "speed" value="10" /><property "sight" value="15" />.... etc<upgrade name="aim_Laser" /><skill name="skill_healer" />.... etc</unit>


[edited by - downgraded on December 26, 2003 10:35:52 PM]

This topic is closed to new replies.

Advertisement