Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Raws Syntax Checker  (Read 648 times)

pwildani

  • Escaped Lunatic
    • View Profile
Raws Syntax Checker
« on: September 12, 2009, 11:24:26 pm »

I've written a rudimentary DF raws parser. It's to the point where it can do basic checks like missing ]'s, duplicate definitions, and very limited checking for tags that don't belong in the current [OBJECT] scope.

Examples:
Code: [Select]
$ $DFCONFIG/config_file.py raw/objects/item_weapon.txt
raw/objects/item_weapon.txt: 22 toplevel objects

Code: [Select]
$ $DFCONFIG/config_file.py raw/objects/item_weapon.txt /tmp/item_weapon_copy.txt
raw/objects/item_weapon.txt: 22 toplevel objects
/tmp/item_weapon_copy.txt:5: [ITEM_WEAPON:ITEM_WEAPON_WHIP]: ITEM_WEAPON_WHIP: defined both here and raw/objects/item_weapon.txt:5

And, after editing item_weapon_copy.txt a little:
Code: [Select]
$ $DFCONFIG/config_file.py /tmp/item_weapon_copy.txt
/tmp/item_weapon_copy.txt:6: Tag is not closed before next [

And typo-ing it a bit more:
Code: [Select]
$ $DFCONFIG/config_file.py /tmp/item_weapon_copy.txt     
/tmp/item_weapon_copy.txt:5: [ITEM_WEPON:ITEM_WEAPON_WHIP]: Unknown top-level tag: [ITEM_WEPON:ITEM_WEAPON_WHIP]

My eventual goal is a tool to assist in merging mods together at a more conceptual level than a text-based merge (shades of modbase!), but it's still far from usable for that. It can preserve comments and formatting though.

It's entirely within the scope of this project to check references to other objects, like reagents, products, and body parts. But noone's done that yet. You could be the first! :)

The code's at: http://github.com/pwildani/dfconfig
It requires python3.
Logged

Untelligent

  • Bay Watcher
  • I eat flesh!
    • View Profile
Re: Raws Syntax Checker
« Reply #1 on: September 12, 2009, 11:28:55 pm »

So what does this do that the game's error log doesn't?
Logged
The World Without Knifebear — A much safer world indeed.
regardless, the slime shooter will be completed, come hell or high water, which are both entirely plausible setbacks at this point.

pwildani

  • Escaped Lunatic
    • View Profile
Re: Raws Syntax Checker
« Reply #2 on: September 12, 2009, 11:39:08 pm »

Tells you about a missing ], with the file and actual line number instead of just a largely useless:
Quote
Unrecognized Creature Token: [TILE
And it does it in seconds rather than taking several minutes for a regen.

It does nothing really significant automatically yet, but I've used it to do a few bulk changes like a global SPEED /= 10 to make things run a bit faster at low FPS without distorting relative creature speeds *too* much and also to confirm that I've merged some mods together without obvious errors.

Logged

Untelligent

  • Bay Watcher
  • I eat flesh!
    • View Profile
Re: Raws Syntax Checker
« Reply #3 on: September 14, 2009, 07:26:40 pm »

And it does it in seconds rather than taking several minutes for a regen.

"Smaller" worlds can gen in seconds too.

The missing ] finder sounds useful, though.
Logged
The World Without Knifebear — A much safer world indeed.
regardless, the slime shooter will be completed, come hell or high water, which are both entirely plausible setbacks at this point.

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: Raws Syntax Checker
« Reply #4 on: September 15, 2009, 10:51:10 am »

Also, if I am right, it checks the top-level tags like ITEM_WEPON.

Sounds really useful, because in case of multiple errors it takes a lot of time to check files with standard search tools.
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository