Socket
Socket
Sign inDemoInstall

messageformat-parser

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messageformat-parser - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

4

package.json
{
"name": "messageformat-parser",
"version": "1.1.0",
"version": "2.0.0",
"description": "A PEG.js parser for ICU MessageFormat strings -- part of messageformat.js",

@@ -29,3 +29,3 @@ "keywords": [

"expect.js": "^0.3.1",
"mocha": "^3.0.2",
"mocha": "^4.0.1",
"pegjs": "^0.10.0"

@@ -32,0 +32,0 @@ },

@@ -146,9 +146,10 @@ /*

peg$c1 = peg$literalExpectation("#", false),
peg$c2 = function() { return { type: 'octothorpe' }; },
peg$c3 = function(str) { return str.join(''); },
peg$c4 = "{",
peg$c5 = peg$literalExpectation("{", false),
peg$c6 = "}",
peg$c7 = peg$literalExpectation("}", false),
peg$c8 = function(arg) {
peg$c2 = function() { return inPlural; },
peg$c3 = function() { return { type: 'octothorpe' }; },
peg$c4 = function(str) { return str.join(''); },
peg$c5 = "{",
peg$c6 = peg$literalExpectation("{", false),
peg$c7 = "}",
peg$c8 = peg$literalExpectation("}", false),
peg$c9 = function(arg) {
return {

@@ -159,7 +160,8 @@ type: 'argument',

},
peg$c9 = ",",
peg$c10 = peg$literalExpectation(",", false),
peg$c11 = "select",
peg$c12 = peg$literalExpectation("select", false),
peg$c13 = function(arg, cases) {
peg$c10 = ",",
peg$c11 = peg$literalExpectation(",", false),
peg$c12 = "select",
peg$c13 = peg$literalExpectation("select", false),
peg$c14 = function(arg, m) { if (options.strictNumberSign) { inPlural = false; } return m; },
peg$c15 = function(arg, cases) {
return {

@@ -171,7 +173,8 @@ type: 'select',

},
peg$c14 = "plural",
peg$c15 = peg$literalExpectation("plural", false),
peg$c16 = "selectordinal",
peg$c17 = peg$literalExpectation("selectordinal", false),
peg$c18 = function(arg, type, offset, cases) {
peg$c16 = "plural",
peg$c17 = peg$literalExpectation("plural", false),
peg$c18 = "selectordinal",
peg$c19 = peg$literalExpectation("selectordinal", false),
peg$c20 = function(arg, m) { inPlural = true; return m; },
peg$c21 = function(arg, type, offset, cases) {
var ls = ((type === 'selectordinal') ? options.ordinal : options.cardinal)

@@ -185,2 +188,3 @@ || ['zero', 'one', 'two', 'few', 'many', 'other'];

});
inPlural = false;
return {

@@ -193,3 +197,3 @@ type: type,

},
peg$c19 = function(arg, key, params) {
peg$c22 = function(arg, key, params) {
return {

@@ -202,60 +206,64 @@ type: 'function',

},
peg$c20 = /^[0-9a-zA-Z$_]/,
peg$c21 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], "$", "_"], false, false),
peg$c22 = /^[^ \t\n\r,.+={}]/,
peg$c23 = peg$classExpectation([" ", "\t", "\n", "\r", ",", ".", "+", "=", "{", "}"], true, false),
peg$c24 = function(key, tokens) { return { key: key, tokens: tokens }; },
peg$c25 = function(tokens) { return tokens; },
peg$c26 = "offset",
peg$c27 = peg$literalExpectation("offset", false),
peg$c28 = ":",
peg$c29 = peg$literalExpectation(":", false),
peg$c30 = function(d) { return d; },
peg$c31 = "=",
peg$c32 = peg$literalExpectation("=", false),
peg$c33 = function(p) { return options.strictFunctionParams; },
peg$c34 = function(p) { return p; },
peg$c35 = function(p) { return p.replace(/^[ \t\n\r]*|[ \t\n\r]*$/g, ''); },
peg$c36 = "''",
peg$c37 = peg$literalExpectation("''", false),
peg$c38 = function() { return "'"; },
peg$c39 = /^[^']/,
peg$c40 = peg$classExpectation(["'"], true, false),
peg$c41 = "'{",
peg$c42 = peg$literalExpectation("'{", false),
peg$c43 = "'",
peg$c44 = peg$literalExpectation("'", false),
peg$c45 = function(str) { return '\u007B'+str.join(''); },
peg$c46 = "'}",
peg$c47 = peg$literalExpectation("'}", false),
peg$c48 = function(str) { return '\u007D'+str.join(''); },
peg$c49 = /^[^{}#\\\0-\x08\x0E-\x1F\x7F]/,
peg$c50 = peg$classExpectation(["{", "}", "#", "\\", ["\0", "\b"], ["\x0E", "\x1F"], "\x7F"], true, false),
peg$c51 = "\\\\",
peg$c52 = peg$literalExpectation("\\\\", false),
peg$c53 = function() { return '\\'; },
peg$c54 = "\\#",
peg$c55 = peg$literalExpectation("\\#", false),
peg$c56 = function() { return '#'; },
peg$c57 = "\\{",
peg$c58 = peg$literalExpectation("\\{", false),
peg$c59 = function() { return '\u007B'; },
peg$c60 = "\\}",
peg$c61 = peg$literalExpectation("\\}", false),
peg$c62 = function() { return '\u007D'; },
peg$c63 = "\\u",
peg$c64 = peg$literalExpectation("\\u", false),
peg$c65 = function(h1, h2, h3, h4) {
peg$c23 = /^[^\t-\r \x85\u200E\u200F\u2028\u2029!-\/:-@[-\^`{-~\xA1-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]/,
peg$c24 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029", ["!", "/"], [":", "@"], ["[", "^"], "`", ["{", "~"], ["\xA1", "\xA7"], "\xA9", "\xAB", "\xAC", "\xAE", "\xB0", "\xB1", "\xB6", "\xBB", "\xBF", "\xD7", "\xF7", ["\u2010", "\u2027"], ["\u2030", "\u203E"], ["\u2041", "\u2053"], ["\u2055", "\u205E"], ["\u2190", "\u245F"], ["\u2500", "\u2775"], ["\u2794", "\u2BFF"], ["\u2E00", "\u2E7F"], ["\u3001", "\u3003"], ["\u3008", "\u3020"], "\u3030", "\uFD3E", "\uFD3F", "\uFE45", "\uFE46"], true, false),
peg$c25 = function(key, tokens) { return { key: key, tokens: tokens }; },
peg$c26 = function(tokens) { return tokens; },
peg$c27 = "offset",
peg$c28 = peg$literalExpectation("offset", false),
peg$c29 = ":",
peg$c30 = peg$literalExpectation(":", false),
peg$c31 = function(d) { return d; },
peg$c32 = "=",
peg$c33 = peg$literalExpectation("=", false),
peg$c34 = function(p) { return options.strictFunctionParams; },
peg$c35 = function(p) { return p; },
peg$c36 = function(p) { return p.replace(whitespaceTrimRE, ''); },
peg$c37 = "''",
peg$c38 = peg$literalExpectation("''", false),
peg$c39 = function() { return "'"; },
peg$c40 = /^[^']/,
peg$c41 = peg$classExpectation(["'"], true, false),
peg$c42 = "'{",
peg$c43 = peg$literalExpectation("'{", false),
peg$c44 = "'",
peg$c45 = peg$literalExpectation("'", false),
peg$c46 = function(str) { return '\u007B'+str.join(''); },
peg$c47 = "'}",
peg$c48 = peg$literalExpectation("'}", false),
peg$c49 = function(str) { return '\u007D'+str.join(''); },
peg$c50 = "'#",
peg$c51 = peg$literalExpectation("'#", false),
peg$c52 = function(str) { return "#"+str.join(''); },
peg$c53 = function(quotedOcto) { return quotedOcto[0]; },
peg$c54 = function(octo) { return !inPlural; },
peg$c55 = function(octo) { return octo; },
peg$c56 = /^[^{}#\\\0-\x08\x0E-\x1F\x7F]/,
peg$c57 = peg$classExpectation(["{", "}", "#", "\\", ["\0", "\b"], ["\x0E", "\x1F"], "\x7F"], true, false),
peg$c58 = "\\\\",
peg$c59 = peg$literalExpectation("\\\\", false),
peg$c60 = function() { return '\\'; },
peg$c61 = "\\#",
peg$c62 = peg$literalExpectation("\\#", false),
peg$c63 = function() { return '#'; },
peg$c64 = "\\{",
peg$c65 = peg$literalExpectation("\\{", false),
peg$c66 = function() { return '\u007B'; },
peg$c67 = "\\}",
peg$c68 = peg$literalExpectation("\\}", false),
peg$c69 = function() { return '\u007D'; },
peg$c70 = "\\u",
peg$c71 = peg$literalExpectation("\\u", false),
peg$c72 = function(h1, h2, h3, h4) {
return String.fromCharCode(parseInt('0x' + h1 + h2 + h3 + h4));
},
peg$c66 = /^[^',}]/,
peg$c67 = peg$classExpectation(["'", ",", "}"], true, false),
peg$c68 = /^[^'}]/,
peg$c69 = peg$classExpectation(["'", "}"], true, false),
peg$c70 = /^[0-9]/,
peg$c71 = peg$classExpectation([["0", "9"]], false, false),
peg$c72 = /^[0-9a-fA-F]/,
peg$c73 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false),
peg$c74 = /^[ \t\n\r]/,
peg$c75 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false),
peg$c73 = /^[^',}]/,
peg$c74 = peg$classExpectation(["'", ",", "}"], true, false),
peg$c75 = /^[^'}]/,
peg$c76 = peg$classExpectation(["'", "}"], true, false),
peg$c77 = /^[0-9]/,
peg$c78 = peg$classExpectation([["0", "9"]], false, false),
peg$c79 = /^[0-9a-fA-F]/,
peg$c80 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false),
peg$c81 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/,
peg$c82 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false),

@@ -431,6 +439,21 @@ peg$currPos = 0,

if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c2();
peg$savedPos = peg$currPos;
s2 = peg$c2();
if (s2) {
s2 = void 0;
} else {
s2 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c3();
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
s0 = s1;
if (s0 === peg$FAILED) {

@@ -450,3 +473,3 @@ s0 = peg$currPos;

peg$savedPos = s0;
s1 = peg$c3(s1);
s1 = peg$c4(s1);
}

@@ -468,7 +491,7 @@ s0 = s1;

if (input.charCodeAt(peg$currPos) === 123) {
s1 = peg$c4;
s1 = peg$c5;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}

@@ -483,11 +506,11 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 125) {
s5 = peg$c6;
s5 = peg$c7;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8(s3);
s1 = peg$c9(s3);
s0 = s1;

@@ -523,7 +546,7 @@ } else {

if (input.charCodeAt(peg$currPos) === 123) {
s1 = peg$c4;
s1 = peg$c5;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}

@@ -538,7 +561,7 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 44) {
s5 = peg$c9;
s5 = peg$c10;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}

@@ -548,9 +571,15 @@ if (s5 !== peg$FAILED) {

if (s6 !== peg$FAILED) {
if (input.substr(peg$currPos, 6) === peg$c11) {
s7 = peg$c11;
s7 = peg$currPos;
if (input.substr(peg$currPos, 6) === peg$c12) {
s8 = peg$c12;
peg$currPos += 6;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c12); }
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c13); }
}
if (s8 !== peg$FAILED) {
peg$savedPos = s7;
s8 = peg$c14(s3, s8);
}
s7 = s8;
if (s7 !== peg$FAILED) {

@@ -560,7 +589,7 @@ s8 = peg$parse_();

if (input.charCodeAt(peg$currPos) === 44) {
s9 = peg$c9;
s9 = peg$c10;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}

@@ -584,11 +613,11 @@ if (s9 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 125) {
s13 = peg$c6;
s13 = peg$c7;
peg$currPos++;
} else {
s13 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s13 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c13(s3, s11);
s1 = peg$c15(s3, s11);
s0 = s1;

@@ -656,7 +685,7 @@ } else {

if (input.charCodeAt(peg$currPos) === 123) {
s1 = peg$c4;
s1 = peg$c5;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}

@@ -671,7 +700,7 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 44) {
s5 = peg$c9;
s5 = peg$c10;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}

@@ -681,18 +710,24 @@ if (s5 !== peg$FAILED) {

if (s6 !== peg$FAILED) {
if (input.substr(peg$currPos, 6) === peg$c14) {
s7 = peg$c14;
s7 = peg$currPos;
if (input.substr(peg$currPos, 6) === peg$c16) {
s8 = peg$c16;
peg$currPos += 6;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c15); }
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c17); }
}
if (s7 === peg$FAILED) {
if (input.substr(peg$currPos, 13) === peg$c16) {
s7 = peg$c16;
if (s8 === peg$FAILED) {
if (input.substr(peg$currPos, 13) === peg$c18) {
s8 = peg$c18;
peg$currPos += 13;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c17); }
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c19); }
}
}
if (s8 !== peg$FAILED) {
peg$savedPos = s7;
s8 = peg$c20(s3, s8);
}
s7 = s8;
if (s7 !== peg$FAILED) {

@@ -702,7 +737,7 @@ s8 = peg$parse_();

if (input.charCodeAt(peg$currPos) === 44) {
s9 = peg$c9;
s9 = peg$c10;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}

@@ -731,11 +766,11 @@ if (s9 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 125) {
s14 = peg$c6;
s14 = peg$c7;
peg$currPos++;
} else {
s14 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s14 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c18(s3, s7, s11, s12);
s1 = peg$c21(s3, s7, s11, s12);
s0 = s1;

@@ -807,7 +842,7 @@ } else {

if (input.charCodeAt(peg$currPos) === 123) {
s1 = peg$c4;
s1 = peg$c5;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}

@@ -822,7 +857,7 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 44) {
s5 = peg$c9;
s5 = peg$c10;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}

@@ -832,3 +867,9 @@ if (s5 !== peg$FAILED) {

if (s6 !== peg$FAILED) {
s7 = peg$parseid();
s7 = peg$currPos;
s8 = peg$parseid();
if (s8 !== peg$FAILED) {
peg$savedPos = s7;
s8 = peg$c14(s3, s8);
}
s7 = s8;
if (s7 !== peg$FAILED) {

@@ -840,11 +881,11 @@ s8 = peg$parse_();

if (input.charCodeAt(peg$currPos) === 125) {
s10 = peg$c6;
s10 = peg$c7;
peg$currPos++;
} else {
s10 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s10 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c19(s3, s7, s9);
s1 = peg$c22(s3, s7, s9);
s0 = s1;

@@ -896,7 +937,7 @@ } else {

function peg$parseid() {
var s0, s1, s2, s3, s4;
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
if (peg$c20.test(input.charAt(peg$currPos))) {
s1 = [];
if (peg$c23.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -906,32 +947,16 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c21); }
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
if (s2 !== peg$FAILED) {
s3 = [];
if (peg$c22.test(input.charAt(peg$currPos))) {
s4 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c23); }
}
while (s4 !== peg$FAILED) {
s3.push(s4);
if (peg$c22.test(input.charAt(peg$currPos))) {
s4 = input.charAt(peg$currPos);
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c23.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c23); }
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
}
if (s3 !== peg$FAILED) {
s2 = [s2, s3];
s1 = s2;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;

@@ -964,3 +989,3 @@ }

peg$savedPos = s0;
s1 = peg$c3(s1);
s1 = peg$c4(s1);
}

@@ -988,3 +1013,3 @@ s0 = s1;

peg$savedPos = s0;
s1 = peg$c3(s1);
s1 = peg$c4(s1);
}

@@ -1009,3 +1034,3 @@ s0 = s1;

peg$savedPos = s0;
s1 = peg$c24(s2, s4);
s1 = peg$c25(s2, s4);
s0 = s1;

@@ -1045,3 +1070,3 @@ } else {

peg$savedPos = s0;
s1 = peg$c24(s2, s4);
s1 = peg$c25(s2, s4);
s0 = s1;

@@ -1073,7 +1098,7 @@ } else {

if (input.charCodeAt(peg$currPos) === 123) {
s1 = peg$c4;
s1 = peg$c5;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}

@@ -1087,7 +1112,7 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 123) {
s5 = peg$c4;
s5 = peg$c5;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}

@@ -1126,11 +1151,11 @@ peg$silentFails--;

if (input.charCodeAt(peg$currPos) === 125) {
s5 = peg$c6;
s5 = peg$c7;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c25(s3);
s1 = peg$c26(s3);
s0 = s1;

@@ -1167,8 +1192,8 @@ } else {

if (s1 !== peg$FAILED) {
if (input.substr(peg$currPos, 6) === peg$c26) {
s2 = peg$c26;
if (input.substr(peg$currPos, 6) === peg$c27) {
s2 = peg$c27;
peg$currPos += 6;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
if (peg$silentFails === 0) { peg$fail(peg$c28); }
}

@@ -1179,7 +1204,7 @@ if (s2 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 58) {
s4 = peg$c28;
s4 = peg$c29;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); }
if (peg$silentFails === 0) { peg$fail(peg$c30); }
}

@@ -1194,3 +1219,3 @@ if (s4 !== peg$FAILED) {

peg$savedPos = s0;
s1 = peg$c30(s6);
s1 = peg$c31(s6);
s0 = s1;

@@ -1236,7 +1261,7 @@ } else {

if (input.charCodeAt(peg$currPos) === 61) {
s1 = peg$c31;
s1 = peg$c32;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c32); }
if (peg$silentFails === 0) { peg$fail(peg$c33); }
}

@@ -1247,3 +1272,3 @@ if (s1 !== peg$FAILED) {

peg$savedPos = s0;
s1 = peg$c30(s2);
s1 = peg$c31(s2);
s0 = s1;

@@ -1275,3 +1300,3 @@ } else {

peg$savedPos = peg$currPos;
s2 = peg$c33(s1);
s2 = peg$c34(s1);
if (s2) {

@@ -1284,3 +1309,3 @@ s2 = peg$FAILED;

peg$savedPos = s0;
s1 = peg$c34(s1);
s1 = peg$c35(s1);
s0 = s1;

@@ -1305,3 +1330,3 @@ } else {

peg$savedPos = peg$currPos;
s2 = peg$c33(s1);
s2 = peg$c34(s1);
if (s2) {

@@ -1314,3 +1339,3 @@ s2 = void 0;

peg$savedPos = s0;
s1 = peg$c34(s1);
s1 = peg$c35(s1);
s0 = s1;

@@ -1337,7 +1362,7 @@ } else {

if (input.charCodeAt(peg$currPos) === 44) {
s2 = peg$c9;
s2 = peg$c10;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}

@@ -1348,3 +1373,3 @@ if (s2 !== peg$FAILED) {

peg$savedPos = s0;
s1 = peg$c34(s3);
s1 = peg$c35(s3);
s0 = s1;

@@ -1374,7 +1399,7 @@ } else {

if (input.charCodeAt(peg$currPos) === 44) {
s2 = peg$c9;
s2 = peg$c10;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}

@@ -1389,3 +1414,3 @@ if (s2 !== peg$FAILED) {

peg$savedPos = s0;
s1 = peg$c35(s4);
s1 = peg$c36(s4);
s0 = s1;

@@ -1420,12 +1445,12 @@ } else {

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c36) {
s1 = peg$c36;
if (input.substr(peg$currPos, 2) === peg$c37) {
s1 = peg$c37;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c37); }
if (peg$silentFails === 0) { peg$fail(peg$c38); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c38();
s1 = peg$c39();
}

@@ -1444,3 +1469,3 @@ s0 = s1;

s1 = [];
if (peg$c39.test(input.charAt(peg$currPos))) {
if (peg$c40.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1450,3 +1475,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c40); }
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}

@@ -1456,3 +1481,3 @@ if (s2 !== peg$FAILED) {

s1.push(s2);
if (peg$c39.test(input.charAt(peg$currPos))) {
if (peg$c40.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1462,3 +1487,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c40); }
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}

@@ -1471,3 +1496,3 @@ }

peg$savedPos = s0;
s1 = peg$c3(s1);
s1 = peg$c4(s1);
}

@@ -1484,8 +1509,8 @@ s0 = s1;

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c41) {
s1 = peg$c41;
if (input.substr(peg$currPos, 2) === peg$c42) {
s1 = peg$c42;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c42); }
if (peg$silentFails === 0) { peg$fail(peg$c43); }
}

@@ -1501,11 +1526,11 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 39) {
s3 = peg$c43;
s3 = peg$c44;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c44); }
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c45(s2);
s1 = peg$c46(s2);
s0 = s1;

@@ -1526,8 +1551,8 @@ } else {

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c46) {
s1 = peg$c46;
if (input.substr(peg$currPos, 2) === peg$c47) {
s1 = peg$c47;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c47); }
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}

@@ -1543,11 +1568,11 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 39) {
s3 = peg$c43;
s3 = peg$c44;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c44); }
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c48(s2);
s1 = peg$c49(s2);
s0 = s1;

@@ -1571,2 +1596,86 @@ } else {

function peg$parsequoted() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$parsequotedCurly();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$currPos;
s2 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c50) {
s3 = peg$c50;
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$parseinapos();
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$parseinapos();
}
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 39) {
s5 = peg$c44;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s2;
s3 = peg$c52(s4);
s2 = s3;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
peg$savedPos = peg$currPos;
s3 = peg$c2();
if (s3) {
s3 = void 0;
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s2 = [s2, s3];
s1 = s2;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c53(s1);
}
s0 = s1;
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 39) {
s0 = peg$c44;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
}
}
return s0;
}
function peg$parsequotedFunctionParams() {

@@ -1578,7 +1687,7 @@ var s0;

if (input.charCodeAt(peg$currPos) === 39) {
s0 = peg$c43;
s0 = peg$c44;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c44); }
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}

@@ -1593,63 +1702,54 @@ }

if (peg$c49.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c50); }
}
s0 = peg$parsedoubleapos();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c51) {
s1 = peg$c51;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c52); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c53();
}
s0 = s1;
s0 = peg$parsequoted();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c54) {
s1 = peg$c54;
peg$currPos += 2;
if (input.charCodeAt(peg$currPos) === 35) {
s1 = peg$c0;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c56();
peg$savedPos = peg$currPos;
s2 = peg$c54(s1);
if (s2) {
s2 = void 0;
} else {
s2 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c55(s1);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c57) {
s1 = peg$c57;
peg$currPos += 2;
if (peg$c56.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c58); }
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c57); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c59();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c60) {
s1 = peg$c60;
if (input.substr(peg$currPos, 2) === peg$c58) {
s1 = peg$c58;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c61); }
if (peg$silentFails === 0) { peg$fail(peg$c59); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c62();
s1 = peg$c60();
}

@@ -1659,21 +1759,75 @@ s0 = s1;

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c63) {
s1 = peg$c63;
if (input.substr(peg$currPos, 2) === peg$c61) {
s1 = peg$c61;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c64); }
if (peg$silentFails === 0) { peg$fail(peg$c62); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsehexDigit();
if (s2 !== peg$FAILED) {
s3 = peg$parsehexDigit();
if (s3 !== peg$FAILED) {
s4 = peg$parsehexDigit();
if (s4 !== peg$FAILED) {
s5 = peg$parsehexDigit();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c65(s2, s3, s4, s5);
s0 = s1;
peg$savedPos = s0;
s1 = peg$c63();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c64) {
s1 = peg$c64;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c65); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c66();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c67) {
s1 = peg$c67;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c68); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c69();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c70) {
s1 = peg$c70;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c71); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parsehexDigit();
if (s2 !== peg$FAILED) {
s3 = peg$parsehexDigit();
if (s3 !== peg$FAILED) {
s4 = peg$parsehexDigit();
if (s4 !== peg$FAILED) {
s5 = peg$parsehexDigit();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c72(s2, s3, s4, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {

@@ -1687,13 +1841,4 @@ peg$currPos = s0;

}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}

@@ -1727,3 +1872,3 @@ }

s1 = [];
if (peg$c66.test(input.charAt(peg$currPos))) {
if (peg$c73.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1733,3 +1878,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c67); }
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}

@@ -1739,3 +1884,3 @@ if (s2 !== peg$FAILED) {

s1.push(s2);
if (peg$c66.test(input.charAt(peg$currPos))) {
if (peg$c73.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1745,3 +1890,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c67); }
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}

@@ -1754,3 +1899,3 @@ }

peg$savedPos = s0;
s1 = peg$c3(s1);
s1 = peg$c4(s1);
}

@@ -1770,3 +1915,3 @@ s0 = s1;

s1 = [];
if (peg$c68.test(input.charAt(peg$currPos))) {
if (peg$c75.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1776,3 +1921,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c69); }
if (peg$silentFails === 0) { peg$fail(peg$c76); }
}

@@ -1782,3 +1927,3 @@ if (s2 !== peg$FAILED) {

s1.push(s2);
if (peg$c68.test(input.charAt(peg$currPos))) {
if (peg$c75.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1788,3 +1933,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c69); }
if (peg$silentFails === 0) { peg$fail(peg$c76); }
}

@@ -1797,3 +1942,3 @@ }

peg$savedPos = s0;
s1 = peg$c3(s1);
s1 = peg$c4(s1);
}

@@ -1811,3 +1956,3 @@ s0 = s1;

s1 = [];
if (peg$c70.test(input.charAt(peg$currPos))) {
if (peg$c77.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1817,3 +1962,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c71); }
if (peg$silentFails === 0) { peg$fail(peg$c78); }
}

@@ -1823,3 +1968,3 @@ if (s2 !== peg$FAILED) {

s1.push(s2);
if (peg$c70.test(input.charAt(peg$currPos))) {
if (peg$c77.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1829,3 +1974,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c71); }
if (peg$silentFails === 0) { peg$fail(peg$c78); }
}

@@ -1848,3 +1993,3 @@ }

if (peg$c72.test(input.charAt(peg$currPos))) {
if (peg$c79.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);

@@ -1854,3 +1999,3 @@ peg$currPos++;

s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c73); }
if (peg$silentFails === 0) { peg$fail(peg$c80); }
}

@@ -1866,3 +2011,3 @@

s1 = [];
if (peg$c74.test(input.charAt(peg$currPos))) {
if (peg$c81.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1872,7 +2017,7 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c75); }
if (peg$silentFails === 0) { peg$fail(peg$c82); }
}
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c74.test(input.charAt(peg$currPos))) {
if (peg$c81.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1882,3 +2027,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c75); }
if (peg$silentFails === 0) { peg$fail(peg$c82); }
}

@@ -1895,2 +2040,8 @@ }

var inPlural = false;
var whitespaceChars = "[\u0009-\u000d \u0085\u200e\u200f\u2028\u2029]*";
var whitespaceTrimRE = new RegExp("^" + whitespaceChars + "|" + whitespaceChars + "$", "g");
peg$result = peg$startRuleFunction();

@@ -1897,0 +2048,0 @@

@@ -11,6 +11,6 @@ # messageformat-parser <a href="http://travis-ci.org/messageformat/parser"><img align="right" alt="Build Status" src="https://secure.travis-ci.org/messageformat/parser.png"></a>

- `cardinal` and `ordinal` – Arrays of valid plural categories for the current
locale, used to validate plural and selectordinal keys. If these are missing
or set to false, the full set of valid [Unicode CLDR] keys is used: `'zero',
'one', 'two', 'few', 'many', 'other'`. To disable this check, pass in an empty
array.
locale, used to validate `plural` and `selectordinal` keys. If these are
missing or set to false, the full set of valid [Unicode CLDR] keys is used:
`'zero', 'one', 'two', 'few', 'many', 'other'`. To disable this check, pass in
an empty array.

@@ -23,2 +23,16 @@ - `strictFunctionParams` – By default, function parameters are split on commas

- `strictNumberSign` – Inside a `plural` or `selectordinal` statement, a pound
symbol (`#`) is replaced with the input number. By default, `#` is also parsed
as a special character in nested statements too, and can be escaped using
apostrophes (`'#'`). Setting `strictNumberSign` to true will make the parser
follow the ICU MessageFormat spec more closely, and only parse `#` as a
special character directly inside a `plural` or `selectordinal` statement.
Outside those, `#` and `'#'` will be parsed as literal text.
The parser only supports the default `DOUBLE_OPTIONAL` [apostrophe mode]. A
single apostrophe only starts quoted literal text if preceded by a curly brace
(`{}`) or a pound symbol (`#`) inside a `plural` or `selectordinal` statement,
depending on the value of `strictNumberSign`. Otherwise, it is a literal
apostrophe. A double apostrophe is always a literal apostrophe.
[ICU MessageFormat]: https://messageformat.github.io/guide/

@@ -29,2 +43,3 @@ [messageformat.js]: https://messageformat.github.io/

[Unicode CLDR]: http://cldr.unicode.org/index/cldr-spec/plural-rules
[apostrophe mode]: http://www.icu-project.org/apiref/icu4c/messagepattern_8h.html#af6e0757e0eb81c980b01ee5d68a9978b

@@ -95,2 +110,4 @@

For more example usage, please take a look at our [test suite](./test.js).
#### Contributor License Agreement

@@ -97,0 +114,0 @@ See the [messageformat.js README][CLA] for details.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc