Linenumber
Hi there.
I am currently writing some sort of generic compiler for angelscript as some ppl may know already. The makefiles work fine, so I concentrate on adding features.
One feature is to some sort of preprocessing to the scriptmanager (it only preprocesses the makefiles, not the scripts to be compiled).
I read the whole file into a std::string just like in the tutorial, but I do it binary. ( If I don't, I always get script-errors with windows-encoded files (crlf), the tutorial may be "wrong" here..)
After that, I run a couple of functions over the code. First, I replace all _FILE_-constants by inserting the real name of the file. Then I want to replace _LINE_. And here is the problem, i don't get behind it, how I can count the number of lines... I tried to use a stringstream, but that doesn't work, because I cant manipulate the strings I retrieve with getline. So I can't count them.. :(. And because I have all in one string, I can't search line by line.
How can I associate the value I get by std::string::find to some sort of linenumber for my _LINE_-Constant?
I am stuck and need some point to the correct direction, hehe.
Thanks in advance.
regeards
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
http://nightlight2d.de/
Have you tried just doing a linear search for '\n' and counting the number of occurrances until the position of the __LINE__ token? Of course, you don't need to do a linear search over the entire string each time if you just remember the position and line number you last queried.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Thanks for your replies.
Uhm, I didn't know boost::wave, I will have an look on that one, perhaps I have use for it, thanks for the advice.
I have solved it via a vector for now. I read it line by line from a stringbuffer and process it line by line and read it back into one single string. That works just as I want it to work for now :).
regards.
Uhm, I didn't know boost::wave, I will have an look on that one, perhaps I have use for it, thanks for the advice.
I have solved it via a vector for now. I read it line by line from a stringbuffer and process it line by line and read it back into one single string. That works just as I want it to work for now :).
regards.
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
http://nightlight2d.de/
Just FYI:
I have re-implemented the feature using boost::wave :).
Thanks for the Tip, even if this library is still somewhat "difficult" for me, but what I want, works.
Now I can add more macros and allow users to #define their own macros :).
regards
I have re-implemented the feature using boost::wave :).
Thanks for the Tip, even if this library is still somewhat "difficult" for me, but what I want, works.
Now I can add more macros and allow users to #define their own macros :).
regards
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
http://nightlight2d.de/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement