Need Help for a parser
-
I've got some problems parsing strings and /* */ comments. Any help will be appreciated. ----------------- // multyline comments case '*': case '/': case '(': case ')': case '+': case '-': case '=': case '~': case '|': case ';': case '%': case '&': case '{': case '}': case ',': case '[': case ']': case '?': case ':': case '^': case '<': case '>': case '!': case '.': substr += s[i]; i++; { if(i < s.Length && (substr == "/")) { if(i < s.Length && (s[i]== '*')) { do { substr += s[i]; i++; } while (i < s.Length && substr== "*/"); rTB2.Text += "Komentar - " + substr + "\n"; substr = ""; } ----------------- case '"': { do { substr += s[i]; i++; } while (i < s.Length && s[i]!='"'); rTB2.Text += "Tekst - " + substr + "\n"; substr = ""; } brake; ----------------- If someone want, here is a direct link to my code. http://www.geocities.com/puma55555/MyC.zip
-
I've got some problems parsing strings and /* */ comments. Any help will be appreciated. ----------------- // multyline comments case '*': case '/': case '(': case ')': case '+': case '-': case '=': case '~': case '|': case ';': case '%': case '&': case '{': case '}': case ',': case '[': case ']': case '?': case ':': case '^': case '<': case '>': case '!': case '.': substr += s[i]; i++; { if(i < s.Length && (substr == "/")) { if(i < s.Length && (s[i]== '*')) { do { substr += s[i]; i++; } while (i < s.Length && substr== "*/"); rTB2.Text += "Komentar - " + substr + "\n"; substr = ""; } ----------------- case '"': { do { substr += s[i]; i++; } while (i < s.Length && s[i]!='"'); rTB2.Text += "Tekst - " + substr + "\n"; substr = ""; } brake; ----------------- If someone want, here is a direct link to my code. http://www.geocities.com/puma55555/MyC.zip
Why not just post your problem here? Few are going to take the time to download, unzip, and study your code on their spare time. Just post the problems you're havnig here and we can help you. Also, if you code is in the C or C++ languages (guessing by your zip name), you're in the wrong forum.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Lent Revisited The apostle Paul, modernly speaking Judah Himango
-
I've got some problems parsing strings and /* */ comments. Any help will be appreciated. ----------------- // multyline comments case '*': case '/': case '(': case ')': case '+': case '-': case '=': case '~': case '|': case ';': case '%': case '&': case '{': case '}': case ',': case '[': case ']': case '?': case ':': case '^': case '<': case '>': case '!': case '.': substr += s[i]; i++; { if(i < s.Length && (substr == "/")) { if(i < s.Length && (s[i]== '*')) { do { substr += s[i]; i++; } while (i < s.Length && substr== "*/"); rTB2.Text += "Komentar - " + substr + "\n"; substr = ""; } ----------------- case '"': { do { substr += s[i]; i++; } while (i < s.Length && s[i]!='"'); rTB2.Text += "Tekst - " + substr + "\n"; substr = ""; } brake; ----------------- If someone want, here is a direct link to my code. http://www.geocities.com/puma55555/MyC.zip
You might be better off using parser generator tool http://www.antlr.org is a good one. You can look at couple of my examples: http://www.codeproject.com/csharp/stringtokenizer.asp[^] or have a look at http://www.adersoftware.com/index.cfm?page=templateEngine2[^] (library with easy to use hand coded lexer/parser) or http://www.adersoftware.com/index.cfm?page=compilers[^]