Commit de5bd622 authored by Rico Tzschichholz's avatar Rico Tzschichholz

scanner: Accept backreferences \1 through \99 in regex literals

https://bugzilla.gnome.org/show_bug.cgi?id=728574
parent bc17dd43
......@@ -457,6 +457,7 @@ TESTS = \
parser/unsupported-property-async.test \
parser/unsupported-property-throws.test \
parser/yield-method.test \
parser/bug728574.vala \
parser/bug749576.vala \
semantic/constant-extern.test \
semantic/constant-value.test \
......
void main () {
var r = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
}
......@@ -240,7 +240,17 @@ public class Vala.Genie.Scanner {
}
break;
default:
Report.error (get_source_reference (token_length_in_chars), "invalid escape sequence");
// back references \1 through \99
if (current[0].isdigit ()) {
current++;
token_length_in_chars++;
if (current[0].isdigit ()) {
current++;
token_length_in_chars++;
}
} else {
Report.error (get_source_reference (token_length_in_chars), "invalid escape sequence");
}
break;
}
} else if (current[0] == '\n') {
......
......@@ -242,7 +242,17 @@ public class Vala.Scanner {
}
break;
default:
Report.error (get_source_reference (token_length_in_chars), "invalid escape sequence");
// back references \1 through \99
if (current[0].isdigit ()) {
current++;
token_length_in_chars++;
if (current[0].isdigit ()) {
current++;
token_length_in_chars++;
}
} else {
Report.error (get_source_reference (token_length_in_chars), "invalid escape sequence");
}
break;
}
} else if (current[0] == '\n') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment