Ran accross a bug in the IDE when trying to parse some JSON data. Turned out it wasn't a problem with my code but the way the IDE (1.0.5) interprets Curly Braces.
Says -
At present this feature is slightly buggy as the IDE will often find (incorrectly) a brace in text that has been "commented out."
The IDE not only finds them "commented out" it also finds them embedded in constant char arrays, Serial.print statements, ect.
This was my offending statement -
if (strstr(clientBuf, "{"") != 0)
After figuring out that this was my problem statement I thought I had to escape the curly brace with a back slash or a double curly brace. After a couple of hours of screwing around with this I finally figured out that my code compiled and ran fine, it was only the IDE making me think I had a problem.
For instance the following code compiles and runs correctly but when you click around in the IDE and try to verify that you've got your braces balanced it looks like your code is screwed up -
writing good language parsers/interpreters is not trivial as you must keep quite some state. a string like print(" use " instead of { "); implies you need to be able to parse string-mode including escapes which can be part of a #define etc.
So as long I have not written a better one I have to "count the blessing" of the current one
robtillaart:
So as long I have not written a better one I have to "count the blessing" of the current one
Knowing how hard it is to do correctly, I wouldn't piff about trying to write my own parser unless I knew I was competent to do it correctly - and even then I probably wouldn't write my own, I'd use somebody elses. Having got this far down the hole, the author surely knows enough to stop digging. But no, maybe just one more shovel will do the trick.