wml parser
Moderator: Forum Moderators
wml parser
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
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
- Elvish_Hunter
- Posts: 1576
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: wml parser
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.
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)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)