tags:

views:

154

answers:

6

for example, right now I have a roll-my-own solution that uses data files that include blocks like:

PlayerCharacter Fighter
  Hitpoints 25
  Strength 10
  StartPosition (0, 0, 0)
  Art
    Model BigBuffGuy
    Footprint LargeFootprint
  end
  InventoryItem Sword
  InventoryItem Shield
  InventoryItem HealthPotion
end
  • human editable (w/ minimal junk characters, ideally)
  • resilient to errors (fewest 'wow i can't parse anything useful anymore' style errors, and thus i've lost all of the data in the rest of the file) - but still able to identify and report them, of course. My example the only complete failure case is missing 'end's.
  • nested structure style data
  • array/list style data
  • customizable foundation types
  • fast

Are there any well known solutions that meet/exceed these requirements?

+6  A: 

Yaml is a good solution and very close to what you have. Search for it.

Bill K
+1  A: 

I second the YAML suggestion. It's extremely easy to edit, very forgiving of mistakes and widely supported (especially among the dynamic languages).

Daniel Spiewak
+1  A: 

I'd say the most common choices are:

  1. JSON (offical site) - very flexible, though the punctuation can take a bit for people to get used to
  2. INI - super simple to use, but a bit limited in data-types
  3. XML - pretty flexible, common, but way too verbose sometimes
davr
A: 

You could try JSON available at: http://www.json.org/

It was designed for javascript and web usage initially. But it's pretty clean, and supported in many languages.

A: 

Lua was designed to be a programming language where the syntax lets you easily use it as a markup language as well, so that you include data files as if they were code. Many computer games use it for their scripting, such as World of Warcraft due to its speed and ease of use. However it's originally designed and maintained for the energy industry so there's a serious background.

Scheme with its S-expressions is also a very nice but different-looking syntax for data. Finally, you've got XML that has the benefit of the most entry-level developers knowing it. You can also roll your own well-defined and efficient parser with a nice development suite such as ANTLR.

jjrv
A: 

I would suggest JSON.

  • Just as readable/editable as YAML
  • If you happen to use for Web then can be eval()'ed into JavaScript objects
  • Probably as cross language as YAML
Ranguard