messageformat-parser
Advanced tools
Comparing version 3.0.0 to 4.0.0
{ | ||
"name": "messageformat-parser", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "A PEG.js parser for ICU MessageFormat strings", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"expect.js": "^0.3.1", | ||
"mocha": "^4.0.1", | ||
"mocha": "^4.1.0", | ||
"pegjs": "^0.10.0" | ||
@@ -32,0 +32,0 @@ }, |
486
parser.js
@@ -163,3 +163,3 @@ /* | ||
peg$c13 = peg$literalExpectation("select", false), | ||
peg$c14 = function(arg, m) { if (options.strictNumberSign) { inPlural = false; } return m; }, | ||
peg$c14 = function(arg, m) { if (options.strict) { inPlural = false; } return m; }, | ||
peg$c15 = function(arg, cases) { | ||
@@ -213,29 +213,49 @@ return { | ||
peg$c33 = peg$literalExpectation("=", false), | ||
peg$c34 = /^[^}]/, | ||
peg$c35 = peg$classExpectation(["}"], true, false), | ||
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 = "'#", | ||
peg$c50 = peg$literalExpectation("'#", false), | ||
peg$c51 = function(str) { return "#"+str.join(''); }, | ||
peg$c52 = function(quotedOcto) { return quotedOcto[0]; }, | ||
peg$c53 = function(octo) { return !inPlural; }, | ||
peg$c54 = function(octo) { return octo; }, | ||
peg$c55 = /^[^{}#\0-\x08\x0E-\x1F\x7F]/, | ||
peg$c56 = peg$classExpectation(["{", "}", "#", ["\0", "\b"], ["\x0E", "\x1F"], "\x7F"], true, false), | ||
peg$c57 = /^[0-9]/, | ||
peg$c58 = peg$classExpectation([["0", "9"]], false, false), | ||
peg$c59 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/, | ||
peg$c60 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false), | ||
peg$c34 = "number", | ||
peg$c35 = peg$literalExpectation("number", false), | ||
peg$c36 = "date", | ||
peg$c37 = peg$literalExpectation("date", false), | ||
peg$c38 = "time", | ||
peg$c39 = peg$literalExpectation("time", false), | ||
peg$c40 = "spellout", | ||
peg$c41 = peg$literalExpectation("spellout", false), | ||
peg$c42 = "ordinal", | ||
peg$c43 = peg$literalExpectation("ordinal", false), | ||
peg$c44 = "duration", | ||
peg$c45 = peg$literalExpectation("duration", false), | ||
peg$c46 = function(key) { return !options.strict && key.toLowerCase() === key && !/^\d/.test(key) }, | ||
peg$c47 = function(key) { return key }, | ||
peg$c48 = function(tokens) { return !options.strict }, | ||
peg$c49 = function(tokens) { return { tokens: tokens } }, | ||
peg$c50 = function(parts) { return { tokens: [parts.join('')] } }, | ||
peg$c51 = /^[^'{}]/, | ||
peg$c52 = peg$classExpectation(["'", "{", "}"], true, false), | ||
peg$c53 = function(p) { return p.join('') }, | ||
peg$c54 = "'", | ||
peg$c55 = peg$literalExpectation("'", false), | ||
peg$c56 = function(quoted) { return quoted }, | ||
peg$c57 = function(p) { return '{' + p.join('') + '}' }, | ||
peg$c58 = "''", | ||
peg$c59 = peg$literalExpectation("''", false), | ||
peg$c60 = function() { return "'"; }, | ||
peg$c61 = /^[^']/, | ||
peg$c62 = peg$classExpectation(["'"], true, false), | ||
peg$c63 = "'{", | ||
peg$c64 = peg$literalExpectation("'{", false), | ||
peg$c65 = function(str) { return '\u007B'+str.join(''); }, | ||
peg$c66 = "'}", | ||
peg$c67 = peg$literalExpectation("'}", false), | ||
peg$c68 = function(str) { return '\u007D'+str.join(''); }, | ||
peg$c69 = "'#", | ||
peg$c70 = peg$literalExpectation("'#", false), | ||
peg$c71 = function(str) { return "#"+str.join(''); }, | ||
peg$c72 = function(quotedOcto) { return quotedOcto[0]; }, | ||
peg$c73 = function(octo) { return !inPlural; }, | ||
peg$c74 = function(octo) { return octo; }, | ||
peg$c75 = /^[^{}#\0-\x08\x0E-\x1F\x7F]/, | ||
peg$c76 = peg$classExpectation(["{", "}", "#", ["\0", "\b"], ["\x0E", "\x1F"], "\x7F"], true, false), | ||
peg$c77 = /^[0-9]/, | ||
peg$c78 = peg$classExpectation([["0", "9"]], false, false), | ||
peg$c79 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/, | ||
peg$c80 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false), | ||
@@ -823,9 +843,3 @@ peg$currPos = 0, | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$currPos; | ||
s8 = peg$parseid(); | ||
if (s8 !== peg$FAILED) { | ||
peg$savedPos = s7; | ||
s8 = peg$c14(s3, s8); | ||
} | ||
s7 = s8; | ||
s7 = peg$parsefunctionKey(); | ||
if (s7 !== peg$FAILED) { | ||
@@ -1186,2 +1200,148 @@ s8 = peg$parse_(); | ||
function peg$parsefunctionKey() { | ||
var s0, s1, s2, s3, s4, s5; | ||
if (input.substr(peg$currPos, 6) === peg$c34) { | ||
s0 = peg$c34; | ||
peg$currPos += 6; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c35); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c36) { | ||
s0 = peg$c36; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c37); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c38) { | ||
s0 = peg$c38; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c39); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 8) === peg$c40) { | ||
s0 = peg$c40; | ||
peg$currPos += 8; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 7) === peg$c42) { | ||
s0 = peg$c42; | ||
peg$currPos += 7; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c43); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 8) === peg$c44) { | ||
s0 = peg$c44; | ||
peg$currPos += 8; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c45); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$currPos; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 6) === peg$c12) { | ||
s2 = peg$c12; | ||
peg$currPos += 6; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c13); } | ||
} | ||
peg$silentFails--; | ||
if (s2 === peg$FAILED) { | ||
s1 = void 0; | ||
} else { | ||
peg$currPos = s1; | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$currPos; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 6) === peg$c16) { | ||
s3 = peg$c16; | ||
peg$currPos += 6; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c17); } | ||
} | ||
peg$silentFails--; | ||
if (s3 === peg$FAILED) { | ||
s2 = void 0; | ||
} else { | ||
peg$currPos = s2; | ||
s2 = peg$FAILED; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$currPos; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 13) === peg$c18) { | ||
s4 = peg$c18; | ||
peg$currPos += 13; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c19); } | ||
} | ||
peg$silentFails--; | ||
if (s4 === peg$FAILED) { | ||
s3 = void 0; | ||
} else { | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parseid(); | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = peg$currPos; | ||
s5 = peg$c46(s4); | ||
if (s5) { | ||
s5 = void 0; | ||
} else { | ||
s5 = peg$FAILED; | ||
} | ||
if (s5 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c47(s4); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parsefunctionParam() { | ||
@@ -1202,15 +1362,23 @@ var s0, s1, s2, s3, s4; | ||
s3 = []; | ||
s4 = peg$parseparamChars(); | ||
if (s4 !== peg$FAILED) { | ||
while (s4 !== peg$FAILED) { | ||
s3.push(s4); | ||
s4 = peg$parseparamChars(); | ||
} | ||
} else { | ||
s3 = peg$FAILED; | ||
s4 = peg$parsetoken(); | ||
while (s4 !== peg$FAILED) { | ||
s3.push(s4); | ||
s4 = peg$parsetoken(); | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c4(s3); | ||
s0 = s1; | ||
peg$savedPos = peg$currPos; | ||
s4 = peg$c48(s3); | ||
if (s4) { | ||
s4 = void 0; | ||
} else { | ||
s4 = peg$FAILED; | ||
} | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c49(s3); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
@@ -1228,2 +1396,37 @@ peg$currPos = s0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parse_(); | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s2 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$parsestrictFunctionParamPart(); | ||
while (s4 !== peg$FAILED) { | ||
s3.push(s4); | ||
s4 = peg$parsestrictFunctionParamPart(); | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c50(s3); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} | ||
@@ -1233,16 +1436,111 @@ return s0; | ||
function peg$parseparamChars() { | ||
var s0; | ||
function peg$parsestrictFunctionParamPart() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$parsedoubleapos(); | ||
s0 = peg$currPos; | ||
s1 = []; | ||
if (peg$c51.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c51.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
} | ||
} | ||
} else { | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c53(s1); | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsequotedCurly(); | ||
s0 = peg$parsedoubleapos(); | ||
if (s0 === peg$FAILED) { | ||
if (peg$c34.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s1 = peg$c54; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseinapos(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s3 = peg$c54; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c56(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c35); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsestrictFunctionParamPart(); | ||
while (s3 !== peg$FAILED) { | ||
s2.push(s3); | ||
s3 = peg$parsestrictFunctionParamPart(); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s3 = peg$c7; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c8); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c57(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} | ||
} | ||
@@ -1258,12 +1556,12 @@ } | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c36) { | ||
s1 = peg$c36; | ||
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$c37); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c59); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c38(); | ||
s1 = peg$c60(); | ||
} | ||
@@ -1282,3 +1580,3 @@ s0 = s1; | ||
s1 = []; | ||
if (peg$c39.test(input.charAt(peg$currPos))) { | ||
if (peg$c61.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1288,3 +1586,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c40); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c62); } | ||
} | ||
@@ -1294,3 +1592,3 @@ if (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c39.test(input.charAt(peg$currPos))) { | ||
if (peg$c61.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1300,3 +1598,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c40); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c62); } | ||
} | ||
@@ -1321,8 +1619,8 @@ } | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c41) { | ||
s1 = peg$c41; | ||
if (input.substr(peg$currPos, 2) === peg$c63) { | ||
s1 = peg$c63; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c42); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
} | ||
@@ -1338,11 +1636,11 @@ if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s3 = peg$c43; | ||
s3 = peg$c54; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c45(s2); | ||
s1 = peg$c65(s2); | ||
s0 = s1; | ||
@@ -1363,8 +1661,8 @@ } else { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c46) { | ||
s1 = peg$c46; | ||
if (input.substr(peg$currPos, 2) === peg$c66) { | ||
s1 = peg$c66; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c47); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c67); } | ||
} | ||
@@ -1380,11 +1678,11 @@ if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s3 = peg$c43; | ||
s3 = peg$c54; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c48(s2); | ||
s1 = peg$c68(s2); | ||
s0 = s1; | ||
@@ -1416,8 +1714,8 @@ } else { | ||
s2 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c49) { | ||
s3 = peg$c49; | ||
if (input.substr(peg$currPos, 2) === peg$c69) { | ||
s3 = peg$c69; | ||
peg$currPos += 2; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c70); } | ||
} | ||
@@ -1433,11 +1731,11 @@ if (s3 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s5 = peg$c43; | ||
s5 = peg$c54; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
if (s5 !== peg$FAILED) { | ||
peg$savedPos = s2; | ||
s3 = peg$c51(s4); | ||
s3 = peg$c71(s4); | ||
s2 = s3; | ||
@@ -1477,3 +1775,3 @@ } else { | ||
peg$savedPos = s0; | ||
s1 = peg$c52(s1); | ||
s1 = peg$c72(s1); | ||
} | ||
@@ -1483,7 +1781,7 @@ s0 = s1; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s0 = peg$c43; | ||
s0 = peg$c54; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
@@ -1513,3 +1811,3 @@ } | ||
peg$savedPos = peg$currPos; | ||
s2 = peg$c53(s1); | ||
s2 = peg$c73(s1); | ||
if (s2) { | ||
@@ -1522,3 +1820,3 @@ s2 = void 0; | ||
peg$savedPos = s0; | ||
s1 = peg$c54(s1); | ||
s1 = peg$c74(s1); | ||
s0 = s1; | ||
@@ -1534,3 +1832,3 @@ } else { | ||
if (s0 === peg$FAILED) { | ||
if (peg$c55.test(input.charAt(peg$currPos))) { | ||
if (peg$c75.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1540,3 +1838,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c76); } | ||
} | ||
@@ -1555,3 +1853,3 @@ } | ||
s1 = []; | ||
if (peg$c57.test(input.charAt(peg$currPos))) { | ||
if (peg$c77.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1561,3 +1859,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c78); } | ||
} | ||
@@ -1567,3 +1865,3 @@ if (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c57.test(input.charAt(peg$currPos))) { | ||
if (peg$c77.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1573,3 +1871,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c78); } | ||
} | ||
@@ -1594,3 +1892,3 @@ } | ||
s1 = []; | ||
if (peg$c59.test(input.charAt(peg$currPos))) { | ||
if (peg$c79.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1600,7 +1898,7 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c80); } | ||
} | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c59.test(input.charAt(peg$currPos))) { | ||
if (peg$c79.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1610,3 +1908,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c80); } | ||
} | ||
@@ -1613,0 +1911,0 @@ } |
@@ -16,15 +16,24 @@ # 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> | ||
- `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. | ||
- `strict` – By default, the parsing applies a few relaxations to the ICU | ||
MessageFormat spec. Setting `strict: true` will disable these relaxations: | ||
- The `argType` of `simpleArg` formatting functions will be restricted to the | ||
set of `number`, `date`, `time`, `spellout`, `ordinal`, and `duration`, | ||
rather than accepting any lower-case identifier that does not start with a | ||
number. | ||
- The optional `argStyle` of `simpleArg` formatting functions will not be | ||
parsed as any other text, but instead as the spec requires: "In | ||
argStyleText, every single ASCII apostrophe begins and ends quoted literal | ||
text, and unquoted {curly braces} must occur in matched pairs." | ||
- 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 | ||
(`'#'`). In strict mode `#` will be parsed as a special character only | ||
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. | ||
The parser only supports the default `DOUBLE_OPTIONAL` [apostrophe mode], in | ||
which a single apostrophe only starts quoted literal text if it immediately | ||
precedes a curly brace `{}`, or a pound symbol `#` if inside a plural format. A | ||
literal apostrophe `'` is represented by either a single `'` or a doubled `''` | ||
apostrophe character. | ||
@@ -134,3 +143,5 @@ [ICU MessageFormat]: https://messageformat.github.io/guide/ | ||
key: Identifier, | ||
param: string | null | ||
param: { | ||
tokens: options.strict ? [string] : (Token | Octothorpe)[] | ||
} | null | ||
} | ||
@@ -145,3 +156,3 @@ | ||
key: Identifier, | ||
tokens: strictNumberSign ? Token[] : (Token | Octothorpe)[] | ||
tokens: options.strict ? Token[] : (Token | Octothorpe)[] | ||
} | ||
@@ -148,0 +159,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64203
1841
169