Fix issue #821: GDScript now accepts single quoted as well as double quoted strings.

This commit is contained in:
Guy Rabiller 2014-10-26 10:33:22 +01:00
parent b38118c5cb
commit f1744c8c31

View File

@ -237,7 +237,9 @@ void GDTokenizerText::_advance() {
while (true) { while (true) {
bool is_node_path=false; bool is_node_path = false;
bool is_string = false;
bool is_string_alt = false;
switch(GETCHAR(0)) { switch(GETCHAR(0)) {
case 0: case 0:
@ -527,13 +529,17 @@ void GDTokenizerText::_advance() {
} }
} break; } break;
case '@': case '@':
if (CharType(GETCHAR(1))!='"') { if( CharType(GETCHAR(1))!='"' && CharType(GETCHAR(1))!='\'' ) {
_make_error("Unexpected '@'"); _make_error("Unexpected '@'");
return; return;
} }
INCPOS(1); INCPOS(1);
is_node_path=true; is_node_path=true;
case '\'':
is_string_alt = true;
case '"': { case '"': {
is_string = is_string_alt ? false : true;
int i=1; int i=1;
String str; String str;
@ -542,8 +548,10 @@ void GDTokenizerText::_advance() {
_make_error("Unterminated String"); _make_error("Unterminated String");
return; return;
} else if (CharType(GETCHAR(i)=='"')) { } else if( CharType(GETCHAR(i)=='"') && is_string ) {
break; break;
} else if( CharType(GETCHAR(i)=='\'') && is_string_alt ) {
break;
} else if (CharType(GETCHAR(i)=='\\')) { } else if (CharType(GETCHAR(i)=='\\')) {
//escaped characters... //escaped characters...
i++; i++;