summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parse/lex.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index 45dde7c0..b5737d30 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -568,33 +568,47 @@ Token Lexer::getTokenInt_RawString(bool is_byte)
}
if( hashes == 0 && ch != '"' ) {
this->ungetc();
+ assert( !is_byte );
return this->getTokenInt_Identifier('r');
}
char terminator = ch;
::std::string val;
+ unsigned terminating_hashes = 0;
for(;;)
{
ch = this->getc();
- if( ch == terminator ) {
- for(unsigned i = 0; i < hashes; i ++)
- {
- ch = this->getc();
- if( ch != '#' ) {
- val += terminator;
- while( i -- )
- val += '#';
- break ;
+ if( terminating_hashes > 0 )
+ {
+ assert(terminating_hashes > 0);
+ if( ch != '#' ) {
+ val += terminator;
+ while( terminating_hashes < hashes ) {
+ val += '#';
}
+ terminating_hashes = 0;
}
- if( hashes == 0 || ch == '#' ) {
- return Token(is_byte ? TOK_BYTESTRING : TOK_STRING, val);
+ else {
+ terminating_hashes -= 1;
+ if( terminating_hashes == 0 ) {
+ break;
+ }
}
}
- else {
- val += ch;
+ else
+ {
+ if( ch == terminator ) {
+ if( hashes == 0 ) {
+ break;
+ }
+ terminating_hashes = hashes;
+ }
+ else {
+ val += ch;
+ }
}
}
+ return Token(is_byte ? TOK_BYTESTRING : TOK_STRING, val);
}
Token Lexer::getTokenInt_Identifier(char leader)
{