summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parse/lex.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index 96b04ae3..5289dd31 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -508,15 +508,38 @@ Token Lexer::getTokenInt()
return Token(TOK_COMMENT, str); }
case BLOCKCOMMENT: {
::std::string str;
+ unsigned int level = 0;
while(true)
{
- if( ch == '*' ) {
+ ch = this->getc();
+
+ if( ch == '/' ) {
+ str.push_back(ch);
ch = this->getc();
- if( ch == '/' ) break;
- this->ungetc();
+ if( ch == '*' ) {
+ level ++;
+ }
+ str.push_back(ch);
+ }
+ else {
+ if( ch == '*' ) {
+ ch = this->getc();
+ if( ch == '/' ) {
+ if( level == 0 )
+ break;
+ level --;
+ str.push_back('*');
+ str.push_back('/');
+ }
+ else {
+ str.push_back('*');
+ str.push_back(ch);
+ }
+ }
+ else {
+ str.push_back(ch);
+ }
}
- str.push_back(ch);
- ch = this->getc();
}
return Token(TOK_COMMENT, str); }
case SINGLEQUOTE: {