intl-messageformat-parser
Advanced tools
Comparing version 2.1.3 to 3.0.0
104
build.js
#!/usr/bin/env node | ||
const peg = require('pegjs') | ||
const tspegjs = require("ts-pegjs"); | ||
const fs = require('fs') | ||
const {outputFileSync} = require('fs-extra') | ||
const grammar = fs.readFileSync('./src/parser.pegjs', 'utf-8') | ||
const peg = require('pegjs'); | ||
const tspegjs = require('ts-pegjs'); | ||
const fs = require('fs'); | ||
const { outputFileSync } = require('fs-extra'); | ||
const grammar = fs.readFileSync('./src/parser.pegjs', 'utf-8'); | ||
// TS | ||
const srcString = peg.generate(grammar, { | ||
plugins: [tspegjs], | ||
output: 'source', | ||
tspegjs: { | ||
customHeader: ` | ||
import { | ||
MessageFormatElement, | ||
LiteralElement, | ||
ArgumentElement, | ||
NumberElement, | ||
DateElement, | ||
TimeElement, | ||
SelectElement, | ||
plugins: [tspegjs], | ||
output: 'source', | ||
tspegjs: { | ||
customHeader: ` | ||
import { | ||
MessageFormatElement, | ||
LiteralElement, | ||
ArgumentElement, | ||
NumberElement, | ||
DateElement, | ||
TimeElement, | ||
SelectElement, | ||
PluralElement, | ||
PluralOrSelectOption, | ||
TYPE | ||
NumberSkeleton, | ||
DateSkeleton, | ||
SKELETON_TYPE, | ||
TYPE, | ||
} from './types'` | ||
}, | ||
returnTypes: { | ||
argument: 'string', | ||
ws: 'string', | ||
digit: 'string', | ||
hexDigit: 'string', | ||
quoteEscapedChar: 'string', | ||
apostrophe: 'string', | ||
escape: 'string', | ||
char: 'string', | ||
chars: 'string', | ||
varName: 'string', | ||
number: 'number', | ||
start: 'MessageFormatElement[]', | ||
message: 'MessageFormatElement[]', | ||
literalElement: 'LiteralElement', | ||
argumentElement: 'ArgumentElement', | ||
selectElement: 'SelectElement', | ||
pluralElement: 'PluralElement', | ||
selectOption: 'PluralOrSelectOption', | ||
pluralOption: 'PluralOrSelectOption', | ||
simpleFormatElement: ` | ||
| NumberElement | ||
| DateElement | ||
| TimeElement | ||
}, | ||
returnTypes: { | ||
argument: 'string', | ||
ws: 'string', | ||
digit: 'string', | ||
hexDigit: 'string', | ||
quoteEscapedChar: 'string', | ||
apostrophe: 'string', | ||
escape: 'string', | ||
char: 'string', | ||
chars: 'string', | ||
varName: 'string', | ||
number: 'number', | ||
start: 'MessageFormatElement[]', | ||
message: 'MessageFormatElement[]', | ||
literalElement: 'LiteralElement', | ||
argumentElement: 'ArgumentElement', | ||
selectElement: 'SelectElement', | ||
pluralElement: 'PluralElement', | ||
selectOption: 'PluralOrSelectOption', | ||
pluralOption: 'PluralOrSelectOption', | ||
numberSkeleton: 'NumberSkeleton', | ||
dateOrTimeSkeleton: 'DateSkeleton', | ||
numberArgStyle: 'string | NumberSkeleton', | ||
dateOrTimeArgStyle: 'string | DateSkeleton', | ||
simpleFormatElement: ` | ||
| NumberElement | ||
| DateElement | ||
| TimeElement | ||
` | ||
} | ||
}) | ||
} | ||
}); | ||
const REGEX = /ParseFunction = \((.*?)\) => (any);/g | ||
const REGEX = /ParseFunction = \((.*?)\) => (any);/g; | ||
outputFileSync('src/parser.ts', srcString.replace(REGEX, 'ParseFunction = ($1) => MessageFormatElement[];')) | ||
outputFileSync( | ||
'src/parser.ts', | ||
srcString.replace(REGEX, 'ParseFunction = ($1) => MessageFormatElement[];') | ||
); |
@@ -6,2 +6,25 @@ # Change Log | ||
# [3.0.0](https://github.com/formatjs/formatjs/compare/intl-messageformat-parser@2.1.3...intl-messageformat-parser@3.0.0) (2019-07-29) | ||
### Bug Fixes | ||
* **intl-messageformat-parser:** fix plural =xx grammar ([1c3c1fc](https://github.com/formatjs/formatjs/commit/1c3c1fc)) | ||
### Features | ||
* **intl-messageformat-parser:** add parser for number skeleton and date skeleton ([#131](https://github.com/formatjs/formatjs/issues/131)) ([dbe6799](https://github.com/formatjs/formatjs/commit/dbe6799)) | ||
* **intl-messageformat-parser:** revamped quote rule ([#134](https://github.com/formatjs/formatjs/issues/134)) ([5661177](https://github.com/formatjs/formatjs/commit/5661177)) | ||
* **intl-messageformat-parser:** support argument skeleton for AST printers ([#133](https://github.com/formatjs/formatjs/issues/133)) ([f1f937d](https://github.com/formatjs/formatjs/commit/f1f937d)) | ||
### BREAKING CHANGES | ||
* **intl-messageformat-parser:** This changes how we escape chars in messages, instead of `\` we now use apostrophe which is more aligned with ICU4J & ICU4C | ||
## [2.1.3](https://github.com/formatjs/formatjs/compare/intl-messageformat-parser@2.1.2...intl-messageformat-parser@2.1.3) (2019-07-25) | ||
@@ -8,0 +31,0 @@ |
@@ -37,5 +37,8 @@ "use strict"; | ||
exports.printAST = printAST; | ||
function printEscapedMessage(message) { | ||
return message.replace(ESAPE_CHARS_REGEXP, function (char) { return ESCAPED_CHARS[char]; }); | ||
} | ||
function printLiteralElement(_a) { | ||
var value = _a.value; | ||
return value.replace(ESAPE_CHARS_REGEXP, function (char) { return ESCAPED_CHARS[char]; }); | ||
return printEscapedMessage(value); | ||
} | ||
@@ -47,4 +50,21 @@ function printArgumentElement(_a) { | ||
function printSimpleFormatElement(el) { | ||
return "{" + el.value + ", " + types_1.TYPE[el.type] + (el.style ? ", " + el.style : '') + "}"; | ||
return "{" + el.value + ", " + types_1.TYPE[el.type] + (el.style ? ", " + printArgumentStyle(el.style) : '') + "}"; | ||
} | ||
function printNumberSkeletonToken(token) { | ||
var stem = token.stem, options = token.options; | ||
return options.length === 0 | ||
? stem | ||
: "" + stem + options.map(function (o) { return "/" + o; }).join(''); | ||
} | ||
function printArgumentStyle(style) { | ||
if (typeof style === 'string') { | ||
return style; | ||
} | ||
else if (style.type === 1 /* date */) { | ||
return "::" + printEscapedMessage(style.pattern); | ||
} | ||
else { | ||
return "::" + style.tokens.map(printNumberSkeletonToken).join(' '); | ||
} | ||
} | ||
function printSelectElement(el) { | ||
@@ -51,0 +71,0 @@ var msg = [ |
@@ -31,2 +31,6 @@ export declare enum TYPE { | ||
} | ||
export declare const enum SKELETON_TYPE { | ||
number = 0, | ||
date = 1 | ||
} | ||
export interface LocationDetails { | ||
@@ -48,8 +52,8 @@ offset: number; | ||
export declare type ArgumentElement = BaseElement<TYPE.argument>; | ||
export interface SimpleFormatElement<T extends TYPE> extends BaseElement<T> { | ||
style?: string; | ||
export interface SimpleFormatElement<T extends TYPE, S extends Skeleton> extends BaseElement<T> { | ||
style?: string | S | null; | ||
} | ||
export declare type NumberElement = SimpleFormatElement<TYPE.number>; | ||
export declare type DateElement = SimpleFormatElement<TYPE.date>; | ||
export declare type TimeElement = SimpleFormatElement<TYPE.time>; | ||
export declare type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>; | ||
export declare type DateElement = SimpleFormatElement<TYPE.date, DateSkeleton>; | ||
export declare type TimeElement = SimpleFormatElement<TYPE.time, DateSkeleton>; | ||
export interface SelectOption { | ||
@@ -74,2 +78,17 @@ id: string; | ||
export declare type MessageFormatElement = LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement; | ||
export interface NumberSkeletonToken { | ||
stem: string; | ||
options: string[]; | ||
} | ||
export interface NumberSkeleton { | ||
type: SKELETON_TYPE.number; | ||
tokens: NumberSkeletonToken[]; | ||
location?: Location; | ||
} | ||
export interface DateSkeleton { | ||
type: SKELETON_TYPE.date; | ||
pattern: string; | ||
location?: Location; | ||
} | ||
export declare type Skeleton = NumberSkeleton | DateSkeleton; | ||
/** | ||
@@ -85,4 +104,6 @@ * Type Guards | ||
export declare function isPluralElement(el: MessageFormatElement): el is PluralElement; | ||
export declare function isNumberSkeleton(el: Skeleton): el is NumberSkeleton; | ||
export declare function isDateSkeleton(el: Skeleton): el is DateSkeleton; | ||
export declare function createLiteralElement(value: string): LiteralElement; | ||
export declare function createNumberElement(value: string, style?: string): NumberElement; | ||
export declare function createNumberElement(value: string, style?: string | null): NumberElement; | ||
export interface Options { | ||
@@ -89,0 +110,0 @@ /** |
@@ -65,2 +65,10 @@ "use strict"; | ||
exports.isPluralElement = isPluralElement; | ||
function isNumberSkeleton(el) { | ||
return el.type === 0 /* number */; | ||
} | ||
exports.isNumberSkeleton = isNumberSkeleton; | ||
function isDateSkeleton(el) { | ||
return el.type === 1 /* date */; | ||
} | ||
exports.isDateSkeleton = isDateSkeleton; | ||
function createLiteralElement(value) { | ||
@@ -67,0 +75,0 @@ return { |
@@ -34,5 +34,8 @@ /* | ||
} | ||
function printEscapedMessage(message) { | ||
return message.replace(ESAPE_CHARS_REGEXP, function (char) { return ESCAPED_CHARS[char]; }); | ||
} | ||
function printLiteralElement(_a) { | ||
var value = _a.value; | ||
return value.replace(ESAPE_CHARS_REGEXP, function (char) { return ESCAPED_CHARS[char]; }); | ||
return printEscapedMessage(value); | ||
} | ||
@@ -44,4 +47,21 @@ function printArgumentElement(_a) { | ||
function printSimpleFormatElement(el) { | ||
return "{" + el.value + ", " + TYPE[el.type] + (el.style ? ", " + el.style : '') + "}"; | ||
return "{" + el.value + ", " + TYPE[el.type] + (el.style ? ", " + printArgumentStyle(el.style) : '') + "}"; | ||
} | ||
function printNumberSkeletonToken(token) { | ||
var stem = token.stem, options = token.options; | ||
return options.length === 0 | ||
? stem | ||
: "" + stem + options.map(function (o) { return "/" + o; }).join(''); | ||
} | ||
function printArgumentStyle(style) { | ||
if (typeof style === 'string') { | ||
return style; | ||
} | ||
else if (style.type === 1 /* date */) { | ||
return "::" + printEscapedMessage(style.pattern); | ||
} | ||
else { | ||
return "::" + style.tokens.map(printNumberSkeletonToken).join(' '); | ||
} | ||
} | ||
function printSelectElement(el) { | ||
@@ -48,0 +68,0 @@ var msg = [ |
@@ -31,2 +31,6 @@ export declare enum TYPE { | ||
} | ||
export declare const enum SKELETON_TYPE { | ||
number = 0, | ||
date = 1 | ||
} | ||
export interface LocationDetails { | ||
@@ -48,8 +52,8 @@ offset: number; | ||
export declare type ArgumentElement = BaseElement<TYPE.argument>; | ||
export interface SimpleFormatElement<T extends TYPE> extends BaseElement<T> { | ||
style?: string; | ||
export interface SimpleFormatElement<T extends TYPE, S extends Skeleton> extends BaseElement<T> { | ||
style?: string | S | null; | ||
} | ||
export declare type NumberElement = SimpleFormatElement<TYPE.number>; | ||
export declare type DateElement = SimpleFormatElement<TYPE.date>; | ||
export declare type TimeElement = SimpleFormatElement<TYPE.time>; | ||
export declare type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>; | ||
export declare type DateElement = SimpleFormatElement<TYPE.date, DateSkeleton>; | ||
export declare type TimeElement = SimpleFormatElement<TYPE.time, DateSkeleton>; | ||
export interface SelectOption { | ||
@@ -74,2 +78,17 @@ id: string; | ||
export declare type MessageFormatElement = LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement; | ||
export interface NumberSkeletonToken { | ||
stem: string; | ||
options: string[]; | ||
} | ||
export interface NumberSkeleton { | ||
type: SKELETON_TYPE.number; | ||
tokens: NumberSkeletonToken[]; | ||
location?: Location; | ||
} | ||
export interface DateSkeleton { | ||
type: SKELETON_TYPE.date; | ||
pattern: string; | ||
location?: Location; | ||
} | ||
export declare type Skeleton = NumberSkeleton | DateSkeleton; | ||
/** | ||
@@ -85,4 +104,6 @@ * Type Guards | ||
export declare function isPluralElement(el: MessageFormatElement): el is PluralElement; | ||
export declare function isNumberSkeleton(el: Skeleton): el is NumberSkeleton; | ||
export declare function isDateSkeleton(el: Skeleton): el is DateSkeleton; | ||
export declare function createLiteralElement(value: string): LiteralElement; | ||
export declare function createNumberElement(value: string, style?: string): NumberElement; | ||
export declare function createNumberElement(value: string, style?: string | null): NumberElement; | ||
export interface Options { | ||
@@ -89,0 +110,0 @@ /** |
@@ -56,2 +56,8 @@ export var TYPE; | ||
} | ||
export function isNumberSkeleton(el) { | ||
return el.type === 0 /* number */; | ||
} | ||
export function isDateSkeleton(el) { | ||
return el.type === 1 /* date */; | ||
} | ||
export function createLiteralElement(value) { | ||
@@ -58,0 +64,0 @@ return { |
{ | ||
"name": "intl-messageformat-parser", | ||
"version": "2.1.3", | ||
"version": "3.0.0", | ||
"description": "Parses ICU Message strings into an AST via JavaScript.", | ||
@@ -44,3 +44,3 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/formatjs/formatjs", | ||
"gitHead": "0a4253ccd32ac4d878b6a9ebb8777f29c0c32201" | ||
"gitHead": "a30fa203c2f1bc5bb4ec76087cb4eb6b5fb9bde2" | ||
} |
1423
src/parser.ts
@@ -16,13 +16,16 @@ // tslint:disable:only-arrow-functions | ||
import { | ||
MessageFormatElement, | ||
LiteralElement, | ||
ArgumentElement, | ||
NumberElement, | ||
DateElement, | ||
TimeElement, | ||
SelectElement, | ||
import { | ||
MessageFormatElement, | ||
LiteralElement, | ||
ArgumentElement, | ||
NumberElement, | ||
DateElement, | ||
TimeElement, | ||
SelectElement, | ||
PluralElement, | ||
PluralOrSelectOption, | ||
TYPE | ||
NumberSkeleton, | ||
DateSkeleton, | ||
SKELETON_TYPE, | ||
TYPE, | ||
} from './types' | ||
@@ -189,6 +192,4 @@ export interface IFilePosition { | ||
const peg$c0 = function(chunks: any): any { | ||
return chunks.reduce(function (all, chunk) { | ||
return all.concat(chunk) | ||
}, []).join('') | ||
const peg$c0 = function(parts: any): any { | ||
return parts.join(''); | ||
}; | ||
@@ -202,9 +203,8 @@ const peg$c1 = function(messageText: any): any { | ||
}; | ||
const peg$c2 = function(chars: any): any { return chars.join(''); }; | ||
const peg$c3 = peg$otherExpectation("argumentElement"); | ||
const peg$c4 = "{"; | ||
const peg$c5 = peg$literalExpectation("{", false); | ||
const peg$c6 = "}"; | ||
const peg$c7 = peg$literalExpectation("}", false); | ||
const peg$c8 = function(value: any): any { | ||
const peg$c2 = peg$otherExpectation("argumentElement"); | ||
const peg$c3 = "{"; | ||
const peg$c4 = peg$literalExpectation("{", false); | ||
const peg$c5 = "}"; | ||
const peg$c6 = peg$literalExpectation("}", false); | ||
const peg$c7 = function(value: any): any { | ||
return { | ||
@@ -216,12 +216,30 @@ type: TYPE.argument, | ||
}; | ||
const peg$c9 = ","; | ||
const peg$c10 = peg$literalExpectation(",", false); | ||
const peg$c11 = "number"; | ||
const peg$c12 = peg$literalExpectation("number", false); | ||
const peg$c13 = "date"; | ||
const peg$c14 = peg$literalExpectation("date", false); | ||
const peg$c15 = "time"; | ||
const peg$c16 = peg$literalExpectation("time", false); | ||
const peg$c17 = function(value: any, type: any, style: any): any { | ||
const peg$c8 = peg$otherExpectation("numberSkeletonId"); | ||
const peg$c9 = /^['\/{}]/; | ||
const peg$c10 = peg$classExpectation(["'", "/", "{", "}"], false, false); | ||
const peg$c11 = peg$anyExpectation(); | ||
const peg$c12 = peg$otherExpectation("numberSkeletonTokenOption"); | ||
const peg$c13 = "/"; | ||
const peg$c14 = peg$literalExpectation("/", false); | ||
const peg$c15 = function(option: any): any { return option; }; | ||
const peg$c16 = peg$otherExpectation("numberSkeletonToken"); | ||
const peg$c17 = function(stem: any, options: any): any { | ||
return {stem: stem, options}; | ||
}; | ||
const peg$c18 = function(tokens: any): any { | ||
return { | ||
type: SKELETON_TYPE.number, | ||
tokens, | ||
...insertLocation() | ||
} | ||
}; | ||
const peg$c19 = "::"; | ||
const peg$c20 = peg$literalExpectation("::", false); | ||
const peg$c21 = function(skeleton: any): any { return skeleton; }; | ||
const peg$c22 = ","; | ||
const peg$c23 = peg$literalExpectation(",", false); | ||
const peg$c24 = "number"; | ||
const peg$c25 = peg$literalExpectation("number", false); | ||
const peg$c26 = function(value: any, type: any, style: any): any { | ||
return { | ||
type : type === 'number' ? TYPE.number : type === 'date' ? TYPE.date : TYPE.time, | ||
@@ -233,10 +251,21 @@ style : style && style[2], | ||
}; | ||
const peg$c18 = "plural"; | ||
const peg$c19 = peg$literalExpectation("plural", false); | ||
const peg$c20 = "selectordinal"; | ||
const peg$c21 = peg$literalExpectation("selectordinal", false); | ||
const peg$c22 = "offset:"; | ||
const peg$c23 = peg$literalExpectation("offset:", false); | ||
const peg$c24 = function(value: any, pluralType: any, offset: any, options: any): any { | ||
const peg$c27 = function(pattern: any): any { | ||
return { | ||
type: SKELETON_TYPE.date, | ||
pattern, | ||
...insertLocation(), | ||
} | ||
}; | ||
const peg$c28 = "date"; | ||
const peg$c29 = peg$literalExpectation("date", false); | ||
const peg$c30 = "time"; | ||
const peg$c31 = peg$literalExpectation("time", false); | ||
const peg$c32 = "plural"; | ||
const peg$c33 = peg$literalExpectation("plural", false); | ||
const peg$c34 = "selectordinal"; | ||
const peg$c35 = peg$literalExpectation("selectordinal", false); | ||
const peg$c36 = "offset:"; | ||
const peg$c37 = peg$literalExpectation("offset:", false); | ||
const peg$c38 = function(value: any, pluralType: any, offset: any, options: any): any { | ||
return { | ||
type : TYPE.plural, | ||
@@ -256,5 +285,5 @@ pluralType: pluralType === 'plural' ? 'cardinal' : 'ordinal', | ||
}; | ||
const peg$c25 = "select"; | ||
const peg$c26 = peg$literalExpectation("select", false); | ||
const peg$c27 = function(value: any, options: any): any { | ||
const peg$c39 = "select"; | ||
const peg$c40 = peg$literalExpectation("select", false); | ||
const peg$c41 = function(value: any, options: any): any { | ||
return { | ||
@@ -273,21 +302,5 @@ type : TYPE.select, | ||
}; | ||
const peg$c28 = "=0"; | ||
const peg$c29 = peg$literalExpectation("=0", false); | ||
const peg$c30 = "=1"; | ||
const peg$c31 = peg$literalExpectation("=1", false); | ||
const peg$c32 = "=2"; | ||
const peg$c33 = peg$literalExpectation("=2", false); | ||
const peg$c34 = "zero"; | ||
const peg$c35 = peg$literalExpectation("zero", false); | ||
const peg$c36 = "one"; | ||
const peg$c37 = peg$literalExpectation("one", false); | ||
const peg$c38 = "two"; | ||
const peg$c39 = peg$literalExpectation("two", false); | ||
const peg$c40 = "few"; | ||
const peg$c41 = peg$literalExpectation("few", false); | ||
const peg$c42 = "many"; | ||
const peg$c43 = peg$literalExpectation("many", false); | ||
const peg$c44 = "other"; | ||
const peg$c45 = peg$literalExpectation("other", false); | ||
const peg$c46 = function(id: any, value: any): any { | ||
const peg$c42 = "="; | ||
const peg$c43 = peg$literalExpectation("=", false); | ||
const peg$c44 = function(id: any, value: any): any { | ||
return { | ||
@@ -299,3 +312,3 @@ id, | ||
}; | ||
const peg$c47 = function(id: any, value: any): any { | ||
const peg$c45 = function(id: any, value: any): any { | ||
return { | ||
@@ -307,40 +320,29 @@ id, | ||
}; | ||
const peg$c48 = peg$otherExpectation("whitespace"); | ||
const peg$c49 = /^[ \t\n\r]/; | ||
const peg$c50 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); | ||
const peg$c51 = peg$otherExpectation("optionalWhitespace"); | ||
const peg$c52 = /^[0-9]/; | ||
const peg$c53 = peg$classExpectation([["0", "9"]], false, false); | ||
const peg$c54 = /^[0-9a-f]/i; | ||
const peg$c55 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true); | ||
const peg$c56 = function(digits: any): any { | ||
const peg$c46 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/; | ||
const peg$c47 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false); | ||
const peg$c48 = /^[!-\/:-@[-\^`{-~\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]/; | ||
const peg$c49 = peg$classExpectation([["!", "/"], [":", "@"], ["[", "^"], "`", ["{", "~"], ["\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"], false, false); | ||
const peg$c50 = peg$otherExpectation("optional whitespace"); | ||
const peg$c51 = /^[0-9]/; | ||
const peg$c52 = peg$classExpectation([["0", "9"]], false, false); | ||
const peg$c53 = function(digits: any): any { | ||
return parseInt(digits.join(''), 10); | ||
}; | ||
const peg$c57 = "'"; | ||
const peg$c58 = peg$literalExpectation("'", false); | ||
const peg$c59 = /^[ \t\n\r,.+={}#]/; | ||
const peg$c60 = peg$classExpectation([" ", "\t", "\n", "\r", ",", ".", "+", "=", "{", "}", "#"], false, false); | ||
const peg$c61 = peg$anyExpectation(); | ||
const peg$c62 = function(char: any): any { return char; }; | ||
const peg$c63 = function(sequence: any): any { return sequence; }; | ||
const peg$c64 = peg$otherExpectation("apostrophe"); | ||
const peg$c65 = /^[^{}\\\0-\x1F\x7F \t\n\r]/; | ||
const peg$c66 = peg$classExpectation(["{", "}", "\\", ["\0", "\x1F"], "\x7F", " ", "\t", "\n", "\r"], true, false); | ||
const peg$c67 = "\\\\"; | ||
const peg$c68 = peg$literalExpectation("\\\\", false); | ||
const peg$c69 = function(): any { return '\\'; }; | ||
const peg$c70 = "\\#"; | ||
const peg$c71 = peg$literalExpectation("\\#", false); | ||
const peg$c72 = function(): any { return '\\#'; }; | ||
const peg$c73 = "\\{"; | ||
const peg$c74 = peg$literalExpectation("\\{", false); | ||
const peg$c75 = function(): any { return '\u007B'; }; | ||
const peg$c76 = "\\}"; | ||
const peg$c77 = peg$literalExpectation("\\}", false); | ||
const peg$c78 = function(): any { return '\u007D'; }; | ||
const peg$c79 = "\\u"; | ||
const peg$c80 = peg$literalExpectation("\\u", false); | ||
const peg$c81 = function(digits: any): any { | ||
return String.fromCharCode(parseInt(digits, 16)); | ||
}; | ||
const peg$c54 = peg$otherExpectation("apostrophe"); | ||
const peg$c55 = "'"; | ||
const peg$c56 = peg$literalExpectation("'", false); | ||
const peg$c57 = peg$otherExpectation("double apostrophes"); | ||
const peg$c58 = "''"; | ||
const peg$c59 = peg$literalExpectation("''", false); | ||
const peg$c60 = function(): any { return `'`; }; | ||
const peg$c61 = /^[{}]/; | ||
const peg$c62 = peg$classExpectation(["{", "}"], false, false); | ||
const peg$c63 = /^[^']/; | ||
const peg$c64 = peg$classExpectation(["'"], true, false); | ||
const peg$c65 = function(escapedChar: any, quotedChars: any): any { | ||
return escapedChar + quotedChars.replace(`''`, `'`); | ||
}; | ||
const peg$c66 = /^[^{}]/; | ||
const peg$c67 = peg$classExpectation(["{", "}"], true, false); | ||
const peg$c68 = peg$otherExpectation("keyword"); | ||
@@ -531,19 +533,163 @@ let peg$currPos = 0; | ||
function peg$parsemessageText(): any { | ||
let s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parsedoubleApostrophes(); | ||
if (s2 === peg$FAILED) { | ||
s2 = peg$parsequotedString(); | ||
if (s2 === peg$FAILED) { | ||
s2 = peg$parseunquotedString(); | ||
} | ||
} | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parsedoubleApostrophes(); | ||
if (s2 === peg$FAILED) { | ||
s2 = peg$parsequotedString(); | ||
if (s2 === peg$FAILED) { | ||
s2 = peg$parseunquotedString(); | ||
} | ||
} | ||
} | ||
} else { | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c0(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parseliteralElement(): LiteralElement { | ||
let s0, s1; | ||
s0 = peg$currPos; | ||
s1 = peg$parsemessageText(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c1(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parseargName(): any { | ||
let s0, s1; | ||
s0 = peg$currPos; | ||
s1 = peg$parsenumber(); | ||
if (s1 === peg$FAILED) { | ||
s1 = peg$parsekeyword(); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s0 = input.substring(s0, peg$currPos); | ||
} else { | ||
s0 = s1; | ||
} | ||
return s0; | ||
} | ||
function peg$parseargumentElement(): ArgumentElement { | ||
let s0, s1, s2, s3, s4, s5; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseargName(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parse_(); | ||
if (s4 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s5 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s5 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s3); | ||
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; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c2); } | ||
} | ||
return s0; | ||
} | ||
function peg$parsenumberSkeletonId(): any { | ||
let s0, s1, s2, s3, s4; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$currPos; | ||
s3 = peg$parse_(); | ||
s3 = peg$currPos; | ||
peg$silentFails++; | ||
s4 = peg$parsepatternWhiteSpace(); | ||
if (s4 === peg$FAILED) { | ||
if (peg$c9.test(input.charAt(peg$currPos))) { | ||
s4 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
} | ||
} | ||
peg$silentFails--; | ||
if (s4 === peg$FAILED) { | ||
s3 = undefined; | ||
} else { | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsechars(); | ||
if (input.length > peg$currPos) { | ||
s4 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parse_(); | ||
if (s5 !== peg$FAILED) { | ||
s3 = [s3, s4, s5]; | ||
s2 = s3; | ||
} else { | ||
peg$currPos = s2; | ||
s2 = peg$FAILED; | ||
} | ||
s3 = [s3, s4]; | ||
s2 = s3; | ||
} else { | ||
@@ -561,14 +707,32 @@ peg$currPos = s2; | ||
s2 = peg$currPos; | ||
s3 = peg$parse_(); | ||
s3 = peg$currPos; | ||
peg$silentFails++; | ||
s4 = peg$parsepatternWhiteSpace(); | ||
if (s4 === peg$FAILED) { | ||
if (peg$c9.test(input.charAt(peg$currPos))) { | ||
s4 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
} | ||
} | ||
peg$silentFails--; | ||
if (s4 === peg$FAILED) { | ||
s3 = undefined; | ||
} else { | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsechars(); | ||
if (input.length > peg$currPos) { | ||
s4 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parse_(); | ||
if (s5 !== peg$FAILED) { | ||
s3 = [s3, s4, s5]; | ||
s2 = s3; | ||
} else { | ||
peg$currPos = s2; | ||
s2 = peg$FAILED; | ||
} | ||
s3 = [s3, s4]; | ||
s2 = s3; | ||
} else { | ||
@@ -587,15 +751,46 @@ peg$currPos = s2; | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c0(s1); | ||
s0 = input.substring(s0, peg$currPos); | ||
} else { | ||
s0 = s1; | ||
} | ||
s0 = s1; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsews(); | ||
if (s1 !== peg$FAILED) { | ||
s0 = input.substring(s0, peg$currPos); | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c8); } | ||
} | ||
return s0; | ||
} | ||
function peg$parsenumberSkeletonTokenOption(): any { | ||
let s0, s1, s2; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 47) { | ||
s1 = peg$c13; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c14); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsenumberSkeletonId(); | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c15(s2); | ||
s0 = s1; | ||
} else { | ||
s0 = s1; | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c12); } | ||
} | ||
@@ -605,12 +800,38 @@ return s0; | ||
function peg$parseliteralElement(): LiteralElement { | ||
let s0, s1; | ||
function peg$parsenumberSkeletonToken(): any { | ||
let s0, s1, s2, s3, s4; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
s1 = peg$parsemessageText(); | ||
s1 = peg$parse_(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c1(s1); | ||
s2 = peg$parsenumberSkeletonId(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$parsenumberSkeletonTokenOption(); | ||
while (s4 !== peg$FAILED) { | ||
s3.push(s4); | ||
s4 = peg$parsenumberSkeletonTokenOption(); | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c17(s2, s3); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
s0 = s1; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c16); } | ||
} | ||
@@ -620,20 +841,53 @@ return s0; | ||
function peg$parsevarName(): string { | ||
function peg$parsenumberSkeleton(): NumberSkeleton { | ||
let s0, s1, s2; | ||
s0 = peg$parsenumber(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parsequoteEscapedChar(); | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parsenumberSkeletonToken(); | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parsequoteEscapedChar(); | ||
s2 = peg$parsenumberSkeletonToken(); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
} else { | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c18(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsenumberArgStyle(): string | NumberSkeleton { | ||
let s0, s1, s2; | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c19) { | ||
s1 = peg$c19; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c20); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsenumberSkeleton(); | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c2(s1); | ||
s1 = peg$c21(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsekeyword(); | ||
} | ||
@@ -643,13 +897,12 @@ return s0; | ||
function peg$parseargumentElement(): ArgumentElement { | ||
let s0, s1, s2, s3, s4, s5; | ||
function peg$parsenumberFormatElement(): any { | ||
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c4; | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
@@ -659,17 +912,94 @@ if (s1 !== peg$FAILED) { | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsevarName(); | ||
s3 = peg$parseargName(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parse_(); | ||
if (s4 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s5 = peg$c6; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
if (s5 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c8(s3); | ||
s0 = s1; | ||
s6 = peg$parse_(); | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c24) { | ||
s7 = peg$c24; | ||
peg$currPos += 6; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c25); } | ||
} | ||
if (s7 !== peg$FAILED) { | ||
s8 = peg$parse_(); | ||
if (s8 !== peg$FAILED) { | ||
s9 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s10 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s10 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
if (s10 !== peg$FAILED) { | ||
s11 = peg$parse_(); | ||
if (s11 !== peg$FAILED) { | ||
s12 = peg$parsenumberArgStyle(); | ||
if (s12 !== peg$FAILED) { | ||
s10 = [s10, s11, s12]; | ||
s9 = s10; | ||
} else { | ||
peg$currPos = s9; | ||
s9 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s9; | ||
s9 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s9; | ||
s9 = peg$FAILED; | ||
} | ||
if (s9 === peg$FAILED) { | ||
s9 = null; | ||
} | ||
if (s9 !== peg$FAILED) { | ||
s10 = peg$parse_(); | ||
if (s10 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s11 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s11 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s11 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c26(s3, s7, s9); | ||
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; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
@@ -695,7 +1025,48 @@ peg$currPos = s0; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
return s0; | ||
} | ||
function peg$parsedateOrTimeSkeleton(): DateSkeleton { | ||
let s0, s1; | ||
s0 = peg$currPos; | ||
s1 = peg$parsemessageText(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c27(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsedateOrTimeArgStyle(): string | DateSkeleton { | ||
let s0, s1, s2; | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c19) { | ||
s1 = peg$c19; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c3); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c20); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsedateOrTimeSkeleton(); | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c21(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsekeyword(); | ||
} | ||
@@ -705,7 +1076,3 @@ return s0; | ||
function peg$parsesimpleFormatElement(): | ||
| NumberElement | ||
| DateElement | ||
| TimeElement | ||
{ | ||
function peg$parsedateOrTimeFormatElement(): any { | ||
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12; | ||
@@ -715,7 +1082,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c4; | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
@@ -725,3 +1092,3 @@ if (s1 !== peg$FAILED) { | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsevarName(); | ||
s3 = peg$parseargName(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -731,7 +1098,7 @@ s4 = peg$parse_(); | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c9; | ||
s5 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
@@ -741,26 +1108,17 @@ if (s5 !== peg$FAILED) { | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c11) { | ||
s7 = peg$c11; | ||
peg$currPos += 6; | ||
if (input.substr(peg$currPos, 4) === peg$c28) { | ||
s7 = peg$c28; | ||
peg$currPos += 4; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c12); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c29); } | ||
} | ||
if (s7 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c13) { | ||
s7 = peg$c13; | ||
if (input.substr(peg$currPos, 4) === peg$c30) { | ||
s7 = peg$c30; | ||
peg$currPos += 4; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c14); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c31); } | ||
} | ||
if (s7 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c15) { | ||
s7 = peg$c15; | ||
peg$currPos += 4; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c16); } | ||
} | ||
} | ||
} | ||
@@ -772,7 +1130,7 @@ if (s7 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s10 = peg$c9; | ||
s10 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s10 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
@@ -782,3 +1140,3 @@ if (s10 !== peg$FAILED) { | ||
if (s11 !== peg$FAILED) { | ||
s12 = peg$parsechars(); | ||
s12 = peg$parsedateOrTimeArgStyle(); | ||
if (s12 !== peg$FAILED) { | ||
@@ -806,11 +1164,11 @@ s10 = [s10, s11, s12]; | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s11 = peg$c6; | ||
s11 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s11 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s11 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c17(s3, s7, s9); | ||
s1 = peg$c26(s3, s7, s9); | ||
s0 = s1; | ||
@@ -865,2 +1223,17 @@ } else { | ||
function peg$parsesimpleFormatElement(): | ||
| NumberElement | ||
| DateElement | ||
| TimeElement | ||
{ | ||
let s0; | ||
s0 = peg$parsenumberFormatElement(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsedateOrTimeFormatElement(); | ||
} | ||
return s0; | ||
} | ||
function peg$parsepluralElement(): PluralElement { | ||
@@ -871,7 +1244,7 @@ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c4; | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
@@ -881,3 +1254,3 @@ if (s1 !== peg$FAILED) { | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsevarName(); | ||
s3 = peg$parseargName(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -887,7 +1260,7 @@ s4 = peg$parse_(); | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c9; | ||
s5 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
@@ -897,16 +1270,16 @@ if (s5 !== peg$FAILED) { | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c18) { | ||
s7 = peg$c18; | ||
if (input.substr(peg$currPos, 6) === peg$c32) { | ||
s7 = peg$c32; | ||
peg$currPos += 6; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c19); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c33); } | ||
} | ||
if (s7 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 13) === peg$c20) { | ||
s7 = peg$c20; | ||
if (input.substr(peg$currPos, 13) === peg$c34) { | ||
s7 = peg$c34; | ||
peg$currPos += 13; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c21); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c35); } | ||
} | ||
@@ -918,7 +1291,7 @@ } | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s9 = peg$c9; | ||
s9 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s9 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
@@ -929,8 +1302,8 @@ if (s9 !== peg$FAILED) { | ||
s11 = peg$currPos; | ||
if (input.substr(peg$currPos, 7) === peg$c22) { | ||
s12 = peg$c22; | ||
if (input.substr(peg$currPos, 7) === peg$c36) { | ||
s12 = peg$c36; | ||
peg$currPos += 7; | ||
} else { | ||
s12 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c37); } | ||
} | ||
@@ -976,11 +1349,11 @@ if (s12 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s15 = peg$c6; | ||
s15 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s15 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s15 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c24(s3, s7, s11, s13); | ||
s1 = peg$c38(s3, s7, s11, s13); | ||
s0 = s1; | ||
@@ -1056,7 +1429,7 @@ } else { | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c4; | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
@@ -1066,3 +1439,3 @@ if (s1 !== peg$FAILED) { | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsevarName(); | ||
s3 = peg$parseargName(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1072,7 +1445,7 @@ s4 = peg$parse_(); | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c9; | ||
s5 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
@@ -1082,8 +1455,8 @@ if (s5 !== peg$FAILED) { | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c25) { | ||
s7 = peg$c25; | ||
if (input.substr(peg$currPos, 6) === peg$c39) { | ||
s7 = peg$c39; | ||
peg$currPos += 6; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c26); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c40); } | ||
} | ||
@@ -1094,7 +1467,7 @@ if (s7 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s9 = peg$c9; | ||
s9 = peg$c22; | ||
peg$currPos++; | ||
} else { | ||
s9 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c10); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
} | ||
@@ -1118,11 +1491,11 @@ if (s9 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s13 = peg$c6; | ||
s13 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s13 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s13 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c27(s3, s11); | ||
s1 = peg$c41(s3, s11); | ||
s0 = s1; | ||
@@ -1186,83 +1559,34 @@ } else { | ||
function peg$parsepluralRuleSelectValue(): any { | ||
let s0; | ||
let s0, s1, s2, s3; | ||
if (input.substr(peg$currPos, 2) === peg$c28) { | ||
s0 = peg$c28; | ||
peg$currPos += 2; | ||
s0 = peg$currPos; | ||
s1 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 61) { | ||
s2 = peg$c42; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c29); } | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c43); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 2) === peg$c30) { | ||
s0 = peg$c30; | ||
peg$currPos += 2; | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsenumber(); | ||
if (s3 !== peg$FAILED) { | ||
s2 = [s2, s3]; | ||
s1 = s2; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c31); } | ||
peg$currPos = s1; | ||
s1 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 2) === peg$c32) { | ||
s0 = peg$c32; | ||
peg$currPos += 2; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c33); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c34) { | ||
s0 = peg$c34; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c35); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 3) === peg$c36) { | ||
s0 = peg$c36; | ||
peg$currPos += 3; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c37); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 3) === peg$c38) { | ||
s0 = peg$c38; | ||
peg$currPos += 3; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c39); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 3) === peg$c40) { | ||
s0 = peg$c40; | ||
peg$currPos += 3; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c42) { | ||
s0 = peg$c42; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c43); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 5) === peg$c44) { | ||
s0 = peg$c44; | ||
peg$currPos += 5; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c45); } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
peg$currPos = s1; | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s0 = input.substring(s0, peg$currPos); | ||
} else { | ||
s0 = s1; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsekeyword(); | ||
} | ||
@@ -1278,3 +1602,3 @@ return s0; | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsechars(); | ||
s2 = peg$parsekeyword(); | ||
if (s2 !== peg$FAILED) { | ||
@@ -1284,7 +1608,7 @@ s3 = peg$parse_(); | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s4 = peg$c4; | ||
s4 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
@@ -1295,11 +1619,11 @@ if (s4 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s6 = peg$c6; | ||
s6 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s6 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s6 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c46(s2, s5); | ||
s1 = peg$c44(s2, s5); | ||
s0 = s1; | ||
@@ -1345,7 +1669,7 @@ } else { | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s4 = peg$c4; | ||
s4 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
@@ -1356,11 +1680,11 @@ if (s4 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s6 = peg$c6; | ||
s6 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s6 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s6 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c47(s2, s5); | ||
s1 = peg$c45(s2, s5); | ||
s0 = s1; | ||
@@ -1395,33 +1719,26 @@ } else { | ||
function peg$parsews(): string { | ||
let s0, s1; | ||
function peg$parsepatternWhiteSpace(): any { | ||
let s0; | ||
peg$silentFails++; | ||
s0 = []; | ||
if (peg$c49.test(input.charAt(peg$currPos))) { | ||
s1 = input.charAt(peg$currPos); | ||
if (peg$c46.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c47); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
while (s1 !== peg$FAILED) { | ||
s0.push(s1); | ||
if (peg$c49.test(input.charAt(peg$currPos))) { | ||
s1 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parsepatternSyntax(): any { | ||
let s0; | ||
if (peg$c48.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c49); } | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c48); } | ||
} | ||
@@ -1437,6 +1754,6 @@ return s0; | ||
s1 = []; | ||
s2 = peg$parsews(); | ||
s2 = peg$parsepatternWhiteSpace(); | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parsews(); | ||
s2 = peg$parsepatternWhiteSpace(); | ||
} | ||
@@ -1451,3 +1768,3 @@ if (s1 !== peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c51); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
} | ||
@@ -1458,12 +1775,33 @@ | ||
function peg$parsedigit(): string { | ||
let s0; | ||
function peg$parsenumber(): number { | ||
let s0, s1, s2; | ||
if (peg$c52.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
s0 = peg$currPos; | ||
s1 = []; | ||
if (peg$c51.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c53); } | ||
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; | ||
@@ -1473,12 +1811,18 @@ return s0; | ||
function peg$parsehexDigit(): string { | ||
let s0; | ||
function peg$parseapostrophe(): string { | ||
let s0, s1; | ||
if (peg$c54.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$silentFails++; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s0 = peg$c55; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c54); } | ||
} | ||
@@ -1488,21 +1832,24 @@ return s0; | ||
function peg$parsenumber(): number { | ||
let s0, s1, s2; | ||
function peg$parsedoubleApostrophes(): any { | ||
let s0, s1; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parsedigit(); | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parsedigit(); | ||
} | ||
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$c59); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c56(s1); | ||
s1 = peg$c60(); | ||
} | ||
s0 = s1; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c57); } | ||
} | ||
@@ -1512,33 +1859,15 @@ return s0; | ||
function peg$parsequoteEscapedChar(): string { | ||
let s0, s1, s2; | ||
function peg$parsequotedString(): any { | ||
let s0, s1, s2, s3, s4, s5; | ||
s0 = peg$currPos; | ||
s1 = peg$currPos; | ||
peg$silentFails++; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s2 = peg$c57; | ||
s1 = peg$c55; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
} | ||
if (s2 === peg$FAILED) { | ||
if (peg$c59.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
} | ||
} | ||
peg$silentFails--; | ||
if (s2 === peg$FAILED) { | ||
s1 = undefined; | ||
} else { | ||
peg$currPos = s1; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
if (input.length > peg$currPos) { | ||
if (peg$c61.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1548,32 +1877,64 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c61); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c62); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c62(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s1 = peg$c57; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseescape(); | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c63(s2); | ||
s0 = s1; | ||
s3 = peg$currPos; | ||
s4 = []; | ||
if (input.substr(peg$currPos, 2) === peg$c58) { | ||
s5 = peg$c58; | ||
peg$currPos += 2; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c59); } | ||
} | ||
if (s5 === peg$FAILED) { | ||
if (peg$c63.test(input.charAt(peg$currPos))) { | ||
s5 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
} | ||
} | ||
while (s5 !== peg$FAILED) { | ||
s4.push(s5); | ||
if (input.substr(peg$currPos, 2) === peg$c58) { | ||
s5 = peg$c58; | ||
peg$currPos += 2; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c59); } | ||
} | ||
if (s5 === peg$FAILED) { | ||
if (peg$c63.test(input.charAt(peg$currPos))) { | ||
s5 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
} | ||
} | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s3 = input.substring(s3, peg$currPos); | ||
} else { | ||
s3 = s4; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s4 = peg$c55; | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
} | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c65(s2, s3); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
@@ -1586,2 +1947,5 @@ s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
@@ -1592,35 +1956,18 @@ | ||
function peg$parseapostrophe(): string { | ||
function peg$parseunquotedString(): any { | ||
let s0, s1; | ||
peg$silentFails++; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s0 = peg$c57; | ||
s0 = peg$currPos; | ||
if (peg$c66.test(input.charAt(peg$currPos))) { | ||
s1 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c67); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseescape(): string { | ||
let s0; | ||
if (peg$c59.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
if (s1 !== peg$FAILED) { | ||
s0 = input.substring(s0, peg$currPos); | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
s0 = s1; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parseapostrophe(); | ||
} | ||
@@ -1630,167 +1977,78 @@ return s0; | ||
function peg$parsechar(): string { | ||
let s0, s1, s2, s3, s4, s5, s6, s7; | ||
function peg$parsekeyword(): any { | ||
let s0, s1, s2, s3, s4; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s1 = peg$c57; | ||
peg$currPos++; | ||
s1 = []; | ||
s2 = peg$currPos; | ||
s3 = peg$currPos; | ||
peg$silentFails++; | ||
s4 = peg$parsepatternWhiteSpace(); | ||
if (s4 === peg$FAILED) { | ||
s4 = peg$parsepatternSyntax(); | ||
} | ||
peg$silentFails--; | ||
if (s4 === peg$FAILED) { | ||
s3 = undefined; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseapostrophe(); | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c63(s2); | ||
s0 = s1; | ||
if (s3 !== peg$FAILED) { | ||
if (input.length > peg$currPos) { | ||
s4 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s3 = [s3, s4]; | ||
s2 = s3; | ||
} else { | ||
peg$currPos = s2; | ||
s2 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
peg$currPos = s2; | ||
s2 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (peg$c65.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c66); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c67) { | ||
s1 = peg$c67; | ||
peg$currPos += 2; | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$currPos; | ||
s3 = peg$currPos; | ||
peg$silentFails++; | ||
s4 = peg$parsepatternWhiteSpace(); | ||
if (s4 === peg$FAILED) { | ||
s4 = peg$parsepatternSyntax(); | ||
} | ||
peg$silentFails--; | ||
if (s4 === peg$FAILED) { | ||
s3 = undefined; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c68); } | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
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; | ||
if (s3 !== peg$FAILED) { | ||
if (input.length > peg$currPos) { | ||
s4 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c71); } | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c72(); | ||
if (s4 !== peg$FAILED) { | ||
s3 = [s3, s4]; | ||
s2 = s3; | ||
} else { | ||
peg$currPos = s2; | ||
s2 = peg$FAILED; | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c73) { | ||
s1 = peg$c73; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c74); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c75(); | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c76) { | ||
s1 = peg$c76; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c77); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c78(); | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c79) { | ||
s1 = peg$c79; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c80); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$currPos; | ||
s3 = peg$currPos; | ||
s4 = peg$parsehexDigit(); | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parsehexDigit(); | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parsehexDigit(); | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parsehexDigit(); | ||
if (s7 !== peg$FAILED) { | ||
s4 = [s4, s5, s6, s7]; | ||
s3 = s4; | ||
} else { | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s3; | ||
s3 = peg$FAILED; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s2 = input.substring(s2, peg$currPos); | ||
} else { | ||
s2 = s3; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c81(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
peg$currPos = s2; | ||
s2 = peg$FAILED; | ||
} | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parsechars(): string { | ||
let s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parsechar(); | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parsechar(); | ||
} | ||
} else { | ||
@@ -1800,6 +2058,11 @@ s1 = peg$FAILED; | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c2(s1); | ||
s0 = input.substring(s0, peg$currPos); | ||
} else { | ||
s0 = s1; | ||
} | ||
s0 = s1; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c68); } | ||
} | ||
@@ -1806,0 +2069,0 @@ return s0; |
@@ -23,3 +23,6 @@ /* | ||
isPluralElement, | ||
TYPE | ||
TYPE, | ||
Skeleton, | ||
SKELETON_TYPE, | ||
NumberSkeletonToken | ||
} from './types'; | ||
@@ -61,4 +64,8 @@ | ||
function printEscapedMessage(message: string): string { | ||
return message.replace(ESAPE_CHARS_REGEXP, char => ESCAPED_CHARS[char]); | ||
} | ||
function printLiteralElement({ value }: LiteralElement) { | ||
return value.replace(ESAPE_CHARS_REGEXP, char => ESCAPED_CHARS[char]); | ||
return printEscapedMessage(value); | ||
} | ||
@@ -73,4 +80,24 @@ | ||
) { | ||
return `{${el.value}, ${TYPE[el.type]}${el.style ? `, ${el.style}` : ''}}`; | ||
return `{${el.value}, ${TYPE[el.type]}${ | ||
el.style ? `, ${printArgumentStyle(el.style)}` : '' | ||
}}`; | ||
} | ||
function printNumberSkeletonToken(token: NumberSkeletonToken): string { | ||
const { stem, options } = token; | ||
return options.length === 0 | ||
? stem | ||
: `${stem}${options.map(o => `/${o}`).join('')}`; | ||
} | ||
function printArgumentStyle(style: string | Skeleton) { | ||
if (typeof style === 'string') { | ||
return style; | ||
} else if (style.type === SKELETON_TYPE.date) { | ||
return `::${printEscapedMessage(style.pattern)}`; | ||
} else { | ||
return `::${style.tokens.map(printNumberSkeletonToken).join(' ')}`; | ||
} | ||
} | ||
function printSelectElement(el: SelectElement) { | ||
@@ -77,0 +104,0 @@ const msg = [ |
@@ -32,2 +32,7 @@ export enum TYPE { | ||
export const enum SKELETON_TYPE { | ||
number, | ||
date | ||
} | ||
export interface LocationDetails { | ||
@@ -52,9 +57,10 @@ offset: number; | ||
export interface SimpleFormatElement<T extends TYPE> extends BaseElement<T> { | ||
style?: string; | ||
export interface SimpleFormatElement<T extends TYPE, S extends Skeleton> | ||
extends BaseElement<T> { | ||
style?: string | S | null; | ||
} | ||
export type NumberElement = SimpleFormatElement<TYPE.number>; | ||
export type DateElement = SimpleFormatElement<TYPE.date>; | ||
export type TimeElement = SimpleFormatElement<TYPE.time>; | ||
export type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>; | ||
export type DateElement = SimpleFormatElement<TYPE.date, DateSkeleton>; | ||
export type TimeElement = SimpleFormatElement<TYPE.time, DateSkeleton>; | ||
@@ -100,2 +106,21 @@ export interface SelectOption { | ||
export interface NumberSkeletonToken { | ||
stem: string; | ||
options: string[]; | ||
} | ||
export interface NumberSkeleton { | ||
type: SKELETON_TYPE.number; | ||
tokens: NumberSkeletonToken[]; | ||
location?: Location; | ||
} | ||
export interface DateSkeleton { | ||
type: SKELETON_TYPE.date; | ||
pattern: string; | ||
location?: Location; | ||
} | ||
export type Skeleton = NumberSkeleton | DateSkeleton; | ||
/** | ||
@@ -129,2 +154,8 @@ * Type Guards | ||
} | ||
export function isNumberSkeleton(el: Skeleton): el is NumberSkeleton { | ||
return el.type === SKELETON_TYPE.number; | ||
} | ||
export function isDateSkeleton(el: Skeleton): el is DateSkeleton { | ||
return el.type === SKELETON_TYPE.date; | ||
} | ||
@@ -140,3 +171,3 @@ export function createLiteralElement(value: string): LiteralElement { | ||
value: string, | ||
style?: string | ||
style?: string | null | ||
): NumberElement { | ||
@@ -143,0 +174,0 @@ return { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
273325
7321