I have thought about a lot of things that I'd like to see in fcomm, some ideas will be kept but here are a few )or, really just one..) that sprang to mind while working with the docs.
Comments in fleet and mission sourcefiles.
Currently the rule is, as far as I understand, that fleetfiles can have comments inside < and > ("less than" and "greater than") and mission files can't have any comments.
I'd really think that the standard C and C++ comments should be accepted in the files
(/* comment */ and // restoflinecomment)
Reasons?
1)If fcomm should keep up with the idea to help peopel to learn to program, you need to have comments that works in other programs. (I've never seen any other language that uses the same type of comments)
2) A uncommented file is something that shouldn't exist at all!
Hmm.. can't think of any more reason just now...
I suppose that the old comment system must be kept, but that's probalby just a small thing...
/Nils-Arne
(More ideas to come later on...)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Personally, i do not comment anything, but that is a flaw of mine. I agree that is FC is to be used as a learning tool, it should be as much like C++ as possable. We should be careful to to push it to far and make the game not as fun. I do not think adding more ways of commenting would ruin it and would be a good idea.
Jason
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I went through the code and found the following comment code
if (token[0] == '<') { //HANDLE COMMENTS
int reading = 1;
int startline = seq.GetLine();
while (reading && !seq.eof()) {
seq.GetToken(token); //skip the comment
if (token[0] == '>')
reading--;
else if (token[0] == '<') //handle nested comments
reading++;
}
if (seq.eof() && reading)
return error(IDS_EOFCOMMENT, "", startline);
continue;
}
This could easly be modified to handle /* and *\. The only problem is that a later section of code looks for a "\". We would have to position the new comments so that the comments "/*" is checked before any other code that may interfear with it. Below is what i think will work. Let me know how wrong it is :)
if (token == '/*') { //HANDLE COMMENTS
int reading = 1;
int startline = seq.GetLine();
while (reading && !seq.eof()) {
seq.GetToken(token); //skip the comment
if (token == '*\')
reading--;
else if (token == '/*') //handle nested comments
reading++;
}
if (seq.eof() && reading)
return error(IDS_EOFCOMMENT, "", startline);
continue;
}
I modified the code for the IF command since it used 2 characters. This can also be altered to add the ability for nested comments. For the "//" comment, we would have to adjust the check to stop at the end of the line. I am still not sure on how to do that yet, probably using the eol() function or somthing simple like that :)
Jason
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've just commit'ed a version that handles /* and */ comments (even nested).
It behaves a bit strange when you use both <> and /* */ comments nested. It only bother to count the nesting levels in the first type it sees. Really no big deal...
//-type comments seems to be a bit harder. See my comment about it in the source.
/Nils-Arne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you download the "nightly CVS tarball" and extract it, I think what you get is a copy of the CVS repository. You can check-out the source from this.
Obviously when doing commits make sure they go to the actual source repository (not the copy on your hard drive). I don't know how convenient it would be with WinCVS to set this up.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think the best way to implement this is a seqfile method (seqfile.h, seqfile.cpp) to move to the next line, skipline() nextline().
I couldn't see why the use of GetLine() didn't work, maybe because a token can cross several lines so the parser doesn't update ::line on every line ending.
um C comments aren't supposed to be nestable :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just placed the updated files in. Fcomm now handles un-nested /* */ comments (it will give an error later on...) and also //-type comments (a small error in seqfile.cpp made the miss of end-of-line)
/Nils-Arne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well you need to use "" for sequences longer than 1 character.
The best way to try out a code idea is to edit the code and see if you can get it working.
I don't think C style comments can be nested so that doesn't need to be handled.
What is the Java comment format? We should support that too.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have thought about a lot of things that I'd like to see in fcomm, some ideas will be kept but here are a few )or, really just one..) that sprang to mind while working with the docs.
Comments in fleet and mission sourcefiles.
Currently the rule is, as far as I understand, that fleetfiles can have comments inside < and > ("less than" and "greater than") and mission files can't have any comments.
I'd really think that the standard C and C++ comments should be accepted in the files
(/* comment */ and // restoflinecomment)
Reasons?
1)If fcomm should keep up with the idea to help peopel to learn to program, you need to have comments that works in other programs. (I've never seen any other language that uses the same type of comments)
2) A uncommented file is something that shouldn't exist at all!
Hmm.. can't think of any more reason just now...
I suppose that the old comment system must be kept, but that's probalby just a small thing...
/Nils-Arne
(More ideas to come later on...)
Personally, i do not comment anything, but that is a flaw of mine. I agree that is FC is to be used as a learning tool, it should be as much like C++ as possable. We should be careful to to push it to far and make the game not as fun. I do not think adding more ways of commenting would ruin it and would be a good idea.
Jason
Please forgive me if my coding below is wrong.
I went through the code and found the following comment code
if (token[0] == '<') { //HANDLE COMMENTS
int reading = 1;
int startline = seq.GetLine();
while (reading && !seq.eof()) {
seq.GetToken(token); //skip the comment
if (token[0] == '>')
reading--;
else if (token[0] == '<') //handle nested comments
reading++;
}
if (seq.eof() && reading)
return error(IDS_EOFCOMMENT, "", startline);
continue;
}
This could easly be modified to handle /* and *\. The only problem is that a later section of code looks for a "\". We would have to position the new comments so that the comments "/*" is checked before any other code that may interfear with it. Below is what i think will work. Let me know how wrong it is :)
if (token == '/*') { //HANDLE COMMENTS
int reading = 1;
int startline = seq.GetLine();
while (reading && !seq.eof()) {
seq.GetToken(token); //skip the comment
if (token == '*\')
reading--;
else if (token == '/*') //handle nested comments
reading++;
}
if (seq.eof() && reading)
return error(IDS_EOFCOMMENT, "", startline);
continue;
}
I modified the code for the IF command since it used 2 characters. This can also be altered to add the ability for nested comments. For the "//" comment, we would have to adjust the check to stop at the end of the line. I am still not sure on how to do that yet, probably using the eol() function or somthing simple like that :)
Jason
Almost forgot. This code is from the cbtcode.cpp module
I've just commit'ed a version that handles /* and */ comments (even nested).
It behaves a bit strange when you use both <> and /* */ comments nested. It only bother to count the nesting levels in the first type it sees. Really no big deal...
//-type comments seems to be a bit harder. See my comment about it in the source.
/Nils-Arne
My code was close to working :)
Off topic - Anyone have any sucess using Wincvs through a firewall. The firewall here does not support HTTP tunnling so i cannot get all the source.
Jason
If you download the "nightly CVS tarball" and extract it, I think what you get is a copy of the CVS repository. You can check-out the source from this.
Obviously when doing commits make sure they go to the actual source repository (not the copy on your hard drive). I don't know how convenient it would be with WinCVS to set this up.
I think the best way to implement this is a seqfile method (seqfile.h, seqfile.cpp) to move to the next line, skipline() nextline().
I couldn't see why the use of GetLine() didn't work, maybe because a token can cross several lines so the parser doesn't update ::line on every line ending.
um C comments aren't supposed to be nestable :)
I just placed the updated files in. Fcomm now handles un-nested /* */ comments (it will give an error later on...) and also //-type comments (a small error in seqfile.cpp made the miss of end-of-line)
/Nils-Arne
Well you need to use "" for sequences longer than 1 character.
The best way to try out a code idea is to edit the code and see if you can get it working.
I don't think C style comments can be nested so that doesn't need to be handled.
What is the Java comment format? We should support that too.
In all the java code I looked at.
hehe perhaps that would be pushing it too far :)