comments in TDF files, but HTTP contains // - howzit work?

comments in TDF files, but HTTP contains // - howzit 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
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

comments in TDF files, but HTTP contains // - howzit work?

Post by Pxtl »

I'm making a parser for all the TDF and FBI files in a mod to do some automation, but I'm confused about one thing: modinfo.tdf contains an URL field. Since most URLs are written HTTP://www.foo.bar.baz.com, isn't the // turning it into a comment and thus turning

URL=http://ta-aa.sourceforge.net;
ModType=1;

into

URL=http:ModType=1;

after the comment preprocessor is through?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Hm you'd have to try.
Maybe comments are ignored before closing semicolon...
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

woudltn that turn out as

URL=http:
ModType=1;

Which would generate a boost::spirit parse error? It does that in the TDFParser clas sI ported to NTai, as lindir had a few mistakes such as that......
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Post by SinbadEV »

Stupid Tim Berners-Lee... why must you have made life so difficult for C programmers...
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Post by Pxtl »

AF wrote:woudltn that turn out as

URL=

Which would generate a boost::spirit parse error? It does that in the TDFParser clas sI ported to NTai, as lindir had a few mistakes such as that......
Depends on 3 things: is the linebreak removed as part of the comment?... is the second equality used? Can values span multiple lines? I coded my own parser in C#, and there I only pay attention to the first '=' sign, so the value of URL becomes

Code: Select all

http:ModType=1; 
or

Code: Select all

http:
ModType=1; 
if you don't strip the linebreak.

which is perfectly allowed by the parser, although very stupid. If the modtype tag is not required, it would explain why it lets you get away with it. I really should just look at the source, but that sounds like work.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Post by Caydr »

If there's any chance the URL line might cause some sort of problem, even on an obscure setup, I guess I should probably cut it. It's not like it's actually used by anything right now.
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Post by PauloMorfeo »

After alot of struggle with it in my mod Editor for Spring, i managed to make a file parser that i was very happy with.

I too ran into that same problem with a line in the mod XTA. All that was needed was to remove the ability for // comments to be everywhere.

In fact i think it could be one of the major advantages of my program because the file parser was so forgiving, that you could use comments /**/ wherever and completely disregarded {} (which, at the present format of the data are irrelevant anyway). That way, people who were having problems like:

Code: Select all

HP= 500;
(notice the space after "=")
or a missing bracket, could use my program to import the mod and export it with the electronical assurance of a perfect syntax.

If you understand C# and want to check it, i can give you a hint on what files and classes to look at and give you some quick hints on how it works.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

I ran into the exact same problem. All i did was look for a : before the //. if there was a :, its a URL, and leave it in. if there wasnt, its a comment, so strip it out. Simple.

My suggestion to make everyones lives easier, make strings have "" around them. then all these problems are solved.
User avatar
SwiftSpear
Classic Community Lead
Posts: 7287
Joined: 12 Aug 2005, 09:29

Post by SwiftSpear »

Isn't there a C++ Command symbol that forces C++ used symbols to render as normal symbols? I remember using it for other stuff... maby I'm just crazy.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

The problem here is that

armcom=command.txt;

In C++ you would have

armcom="commander.txt" but there're no quotes here. C++ doesnt count // as comments if it's inside quotes
Firenu
Posts: 39
Joined: 29 Apr 2006, 00:49

Post by Firenu »

for the parser i suppose it could be solved like in java strings. for instance \n means new line in a java string, so if you actually want to print \ and n, you do \\ because \\ means \ :P

"moo\n" = moo then a new line
"\\" = the character \
"\t" = tab

would make it something like http:\/\/site.com ... yuck never mind :D
esteroth12
Posts: 501
Joined: 18 May 2006, 21:19

Post by esteroth12 »

Firenu wrote:for the parser i suppose it could be solved like in java strings. for instance \n means new line in a java string, so if you actually want to print \ and n, you do \\ because \\ means \ :P

"moo\n" = moo then a new line
"\" = the character \
"\t" = tab

would make it something like http:\/\/site.com ... yuck never mind :D
lol a 1337 W! :P

yeah, I'm pretty sure Java and C++ have the same escape commands (\\=\, \n=newline, \a=beep(alert), etc.)

although... i don't really know much about Java...
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

as far as i know, most programming languages have that. C, PHP, Java, Javascript, everything i can think of except VB has it.
Post Reply

Return to “Engine”