@@ -19,11 +19,11 @@ import {
1919
2020// This regex is used to iterate through the beginnings of messages and terms.
2121// With the /m flag, the ^ matches at the beginning of every line.
22- const RE_MESSAGE_START = / ^ ( - ? [ a - z A - Z ] [ \w - ] * ) * = * / gm;
22+ const RE_MESSAGE_START = / ^ (?< ! \r ) ( - ? [ a - z A - Z ] [ \w - ] * ) * = * / gm;
2323
2424// Both Attributes and Variants are parsed in while loops. These regexes are
2525// used to break out of them.
26- const RE_ATTRIBUTE_START = / \. ( [ a - z A - Z ] [ \w - ] * ) * = * / y;
26+ const RE_ATTRIBUTE_START = / (?< = \n * ) \. ( [ a - z A - Z ] [ \w - ] * ) * = * / y;
2727const RE_VARIANT_START = / \* ? \[ / y;
2828
2929const RE_NUMBER_LITERAL = / ( - ? [ 0 - 9 ] + (?: \. ( [ 0 - 9 ] + ) ) ? ) / y;
@@ -37,8 +37,8 @@ const RE_FUNCTION_NAME = /^[A-Z][A-Z0-9_-]*$/;
3737// if the next line is indented. For StringLiterals they are: \ (starts an
3838// escape sequence), " (ends the literal), and line breaks which are not allowed
3939// in StringLiterals. Note that string runs may be empty; text runs may not.
40- const RE_TEXT_RUN = / ( [ ^ { } \n \r ] + ) / y;
41- const RE_STRING_RUN = / ( [ ^ \\ " \n \r ] * ) / y;
40+ const RE_TEXT_RUN = / ( (?: [ ^ { } \n \r ] | \r (? ! \n ) ) + ) / y;
41+ const RE_STRING_RUN = / ( (?: [ ^ \\ " \n \r ] | \r (? ! \n ) ) * ) / y;
4242
4343// Escape sequences.
4444const RE_STRING_ESCAPE = / \\ ( [ \\ " ] ) / y;
@@ -53,17 +53,17 @@ const RE_BLANK_LINES = / *\r?\n/g;
5353const RE_INDENT = / ( * ) $ / ;
5454
5555// Common tokens.
56- const TOKEN_BRACE_OPEN = / { \s * / y;
57- const TOKEN_BRACE_CLOSE = / \s * } / y;
58- const TOKEN_BRACKET_OPEN = / \[ \s * / y;
59- const TOKEN_BRACKET_CLOSE = / \s * ] * / y;
60- const TOKEN_PAREN_OPEN = / \s * \( \s * / y;
61- const TOKEN_ARROW = / \s * - > \s * / y;
62- const TOKEN_COLON = / \s * : \s * / y;
56+ const TOKEN_BRACE_OPEN = / { (?: | \r ? \n ) * / y;
57+ const TOKEN_BRACE_CLOSE = / (?: | \r ? \n ) * } / y;
58+ const TOKEN_BRACKET_OPEN = / \[ (?: | \r ? \n ) * / y;
59+ const TOKEN_BRACKET_CLOSE = / (?: | \r ? \n ) * ] * / y;
60+ const TOKEN_PAREN_OPEN = / (?: | \r ? \n ) * \( (?: | \r ? \n ) * / y;
61+ const TOKEN_ARROW = / (?: | \r ? \n ) * - > (?: | \r ? \n ) * / y;
62+ const TOKEN_COLON = / (?: | \r ? \n ) * : (?: | \r ? \n ) * / y;
6363// Note the optional comma. As a deviation from the Fluent EBNF, the parser
6464// doesn't enforce commas between call arguments.
65- const TOKEN_COMMA = / \s * , ? \s * / y;
66- const TOKEN_BLANK = / \s + / y;
65+ const TOKEN_COMMA = / (?: | \r ? \n ) * , ? (?: | \r ? \n ) * / y;
66+ const TOKEN_BLANK = / (?: | \r ? \n ) + / y;
6767
6868/**
6969 * Fluent Resource is a structure storing parsed localization entries.
0 commit comments