comments in TDF files, but HTTP contains // - howzit work?
Moderator: Moderators
comments in TDF files, but HTTP contains // - howzit work?
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?
URL=http://ta-aa.sourceforge.net;
ModType=1;
into
URL=http:ModType=1;
after the comment preprocessor is through?
Stupid Tim Berners-Lee... why must you have made life so difficult for C programmers...
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 becomesAF 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......
Code: Select all
http:ModType=1;
Code: Select all
http:
ModType=1;
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.
- PauloMorfeo
- Posts: 2004
- Joined: 15 Dec 2004, 20:53
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:
(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.
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;
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.
- SwiftSpear
- Classic Community Lead
- Posts: 7287
- Joined: 12 Aug 2005, 09:29
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 \ 
"moo\n" = moo then a new line
"\\" = the character \
"\t" = tab
would make it something like http:\/\/site.com ... yuck never mind :D

"moo\n" = moo then a new line
"\\" = the character \
"\t" = tab
would make it something like http:\/\/site.com ... yuck never mind :D
-
- Posts: 501
- Joined: 18 May 2006, 21:19
lol a 1337 W!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 \
"moo\n" = moo then a new line
"\" = the character \
"\t" = tab
would make it something like http:\/\/site.com ... yuck never mind :D

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...