wml parser

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
g6b0r
Posts: 1
Joined: September 23rd, 2015, 7:04 am

wml parser

Post by g6b0r »

hilo,

absolutely newby question: if I want to create some tool (using python or java) to edit/configure campaigns, where can I find wml parser code that I could reuse?

thanks!

g6b0r
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: wml parser

Post by Elvish_Hunter »

Moved to Coder's Corner.
In the data/tools/wesnoth directory you can find two Python modules: wmlparser (and its Python 3 counterpart: wmlparser3) and wmlparser2.
The difference between the two modules is that wmlparser(3) is completely written in Python, and has some limitations (by reading it, I found a comment inside of it stating that it doesn't perform recursive macro substitution); wmlparser2, instead, relies on Wesnoth's executable, which is called with the --preprocessor option and spawned as a subprocess.
As you can easily understand, the main problem when writing a WML parser is handling repeated macro substitution, which can be a real pain.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Post Reply