How does TDF file parser actually work?

How does TDF file parser actually work?

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

How does TDF file parser actually work?

Post by TradeMark »

I have been wondering that for a while, because spring can read tdf files which have errors, if i am right...?
Like if some line doesnt have ; in the end, it can still read the file, which is bad thing for validation...

And i just noticed that when some modinfo.tdf has URL=http://something.com; it should be commented? so it would be parsed as: URL=http: or etc...

What are the rules what spring engine uses when it reads the TDF files?
I have been making tdf file reader with PHP, and once a while i find new errors like that...

And does spring support multiline values for variables? Like:

Code: Select all

something=

many

different


lines

;
Is there any page where is information about TDF file parser in spring?
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

You can always nick the TDF parser from my modweb (latest version here), its written for PHP and seems to work pretty well. But as for your questions, i dunno, i just wrote something that seems to work.
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Re: How does TDF file parser actually work?

Post by PauloMorfeo »

TradeMark wrote:...
Like if some line doesnt have ; in the end, it can still read the file, ...
You are somewhat right, globaly, but i think you are wrong about that specific case. A missing ";" will always fail. Although a ";;" will be accepted amd throw a warning of "junk in file x.y".

I think they use a code parser from the C++ library "boost".
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Post by TradeMark »

Maelstrom wrote:You can always nick the TDF parser from my modweb (latest version here), its written for PHP and seems to work pretty well. But as for your questions, i dunno, i just wrote something that seems to work.
Cool, looks better than mine, can i use it in my mod editor (Modit) ? If i have time to look how it works and write lots of code again...
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

You can use it anywhere, GPL and all. Basically you just send the contents of a file (not the file name, a string containing the actual contents of the file) to InputFile() and it returns an array. Parse a map or mod sidedata file and then do a print_r() or var_dump() on it to see how the array is made.

This does allow for multi line values, and is fairly accepting of files, as long as they are made basically correctly. Im not sure what it would do with a ;; though, it might be worth testing.
Post Reply

Return to “Engine”