Hi, people!
Well, I'm having a very weird problem here. I'm loading a textfile using LocalFIleSystem, and as the data is loaded from the file a lexical analyser checks whether the content is well written (the file contains some rules for a knowledge based system, and is written in a particular knowledge representation language). So, the file is readed line by line and, as soon as the line is readed, the lexical analyser analyses it. The problem is: at some point of the lexical analyser the program freezes. Here is a little piece of code from the lexical analyser that will be of interest:
...
string strToken; // string that will store a token from the file with the rules.
char charFile; // a charactere extracted from file.
...
strToken += charFile; // appends, given certain conditions, the character readed to the current token.
...
I added some printf's along the code to help me isolate the problem, and I discovered that it is happening on the concatenation of the string with the char (last line on the code above). I mean, the last "printf" that I could see on the serial terminal screen was the one before that line. But here is the weirdest part: it does not occur on every concatenation. The code runs well until a particular concatenation, where it freezes.
Then I changed every concatenation to:
...
strToken = strToken + charFile;
...
After making that change, the concatenation that was failing started to work, and the code started to fail at some other concatenation, even after changing all the others to the above format.
I already tried use ANSI C strings instead of std::strings, std::stringstream instead of reading from a file, and the maximum that I achieved was changing the concatenation where the program freezes. I am out of ideas about how to sove this. Does anyone have any ideas? Any suggestions? Please, I'm really desperate, anything may be helpful...
Thanks in advance!
Hi, people!
Well, I'm having a very weird problem here. I'm loading a textfile using LocalFIleSystem, and as the data is loaded from the file a lexical analyser checks whether the content is well written (the file contains some rules for a knowledge based system, and is written in a particular knowledge representation language). So, the file is readed line by line and, as soon as the line is readed, the lexical analyser analyses it. The problem is: at some point of the lexical analyser the program freezes. Here is a little piece of code from the lexical analyser that will be of interest:
I added some printf's along the code to help me isolate the problem, and I discovered that it is happening on the concatenation of the string with the char (last line on the code above). I mean, the last "printf" that I could see on the serial terminal screen was the one before that line. But here is the weirdest part: it does not occur on every concatenation. The code runs well until a particular concatenation, where it freezes.
Then I changed every concatenation to:
After making that change, the concatenation that was failing started to work, and the code started to fail at some other concatenation, even after changing all the others to the above format.
I already tried use ANSI C strings instead of std::strings, std::stringstream instead of reading from a file, and the maximum that I achieved was changing the concatenation where the program freezes. I am out of ideas about how to sove this. Does anyone have any ideas? Any suggestions? Please, I'm really desperate, anything may be helpful...
Thanks in advance!