fluent-syntax
Advanced tools
Comparing version 0.12.0 to 0.13.0
# Changelog | ||
## fluent-syntax 0.13.0 (April 17, 2019) | ||
- Support Fluent Syntax 1.0. | ||
Fluent Syntax 1.0 has been published today. There are no changes to the | ||
grammar nor the AST compared to the Syntax 0.9. | ||
## fluent-syntax 0.12.0 (March 26, 2019) | ||
@@ -4,0 +11,0 @@ |
194
compat.js
@@ -1,7 +0,7 @@ | ||
/* fluent-syntax@0.12.0 */ | ||
/* fluent-syntax@0.13.0 */ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define('fluent-syntax', ['exports'], factory) : | ||
(factory((global.FluentSyntax = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
(global = global || self, factory(global.FluentSyntax = {})); | ||
}(this, function (exports) { 'use strict'; | ||
@@ -120,6 +120,4 @@ /* | ||
var _arr = Object.keys(this); | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
const prop = _arr[_i]; | ||
for (var _i = 0, _Object$keys = Object.keys(this); _i < _Object$keys.length; _i++) { | ||
const prop = _Object$keys[_i]; | ||
clone[prop] = visit(this[prop]); | ||
@@ -527,3 +525,3 @@ } | ||
return `Expected token: "${token}"`; | ||
return "Expected token: \"".concat(token, "\""); | ||
} | ||
@@ -536,3 +534,3 @@ | ||
return `Expected a character from range: "${range}"`; | ||
return "Expected a character from range: \"".concat(range, "\""); | ||
} | ||
@@ -545,3 +543,3 @@ | ||
return `Expected message "${id}" to have a value or attributes`; | ||
return "Expected message \"".concat(id, "\" to have a value or attributes"); | ||
} | ||
@@ -554,3 +552,3 @@ | ||
return `Expected term "-${id}" to have a value`; | ||
return "Expected term \"-".concat(id, "\" to have a value"); | ||
} | ||
@@ -614,3 +612,3 @@ | ||
return `Unknown escape sequence: \\${char}.`; | ||
return "Unknown escape sequence: \\".concat(char, "."); | ||
} | ||
@@ -623,3 +621,3 @@ | ||
return `Invalid Unicode escape sequence: ${sequence}.`; | ||
return "Invalid Unicode escape sequence: ".concat(sequence, "."); | ||
} | ||
@@ -1030,4 +1028,4 @@ | ||
for (var _i = 0; _i < methodNames.length; _i++) { | ||
const name = methodNames[_i]; | ||
for (var _i = 0, _methodNames = methodNames; _i < _methodNames.length; _i++) { | ||
const name = _methodNames[_i]; | ||
this[name] = withSpan(this[name]); | ||
@@ -1201,19 +1199,19 @@ } | ||
let Comment$$1; | ||
let Comment$1; | ||
switch (level) { | ||
case 0: | ||
Comment$$1 = Comment; | ||
Comment$1 = Comment; | ||
break; | ||
case 1: | ||
Comment$$1 = GroupComment; | ||
Comment$1 = GroupComment; | ||
break; | ||
case 2: | ||
Comment$$1 = ResourceComment; | ||
Comment$1 = ResourceComment; | ||
break; | ||
} | ||
return new Comment$$1(content); | ||
return new Comment$1(content); | ||
} | ||
@@ -1383,3 +1381,3 @@ | ||
ps.next(); | ||
value += `-${this.getDigits(ps)}`; | ||
value += "-".concat(this.getDigits(ps)); | ||
} else { | ||
@@ -1391,3 +1389,3 @@ value += this.getDigits(ps); | ||
ps.next(); | ||
value += `.${this.getDigits(ps)}`; | ||
value += ".".concat(this.getDigits(ps)); | ||
} | ||
@@ -1438,3 +1436,3 @@ | ||
} else { | ||
var commonIndentLength = Infinity; | ||
commonIndentLength = Infinity; | ||
} | ||
@@ -1606,3 +1604,3 @@ | ||
ps.next(); | ||
return `\\${next}`; | ||
return "\\".concat(next); | ||
@@ -1628,3 +1626,3 @@ case "u": | ||
if (!ch) { | ||
throw new ParseError("E0026", `\\${u}${sequence}${ps.currentChar}`); | ||
throw new ParseError("E0026", "\\".concat(u).concat(sequence).concat(ps.currentChar)); | ||
} | ||
@@ -1635,3 +1633,3 @@ | ||
return `\\${u}${sequence}`; | ||
return "\\".concat(u).concat(sequence); | ||
} | ||
@@ -1867,3 +1865,3 @@ | ||
if (resource.type !== "Resource") { | ||
throw new Error(`Unknown resource type: ${resource.type}`); | ||
throw new Error("Unknown resource type: ".concat(resource.type)); | ||
} | ||
@@ -1919,20 +1917,20 @@ | ||
if (state & HAS_ENTRIES) { | ||
return `\n${serializeComment(entry, "#")}\n`; | ||
return "\n".concat(serializeComment(entry, "#"), "\n"); | ||
} | ||
return `${serializeComment(entry, "#")}\n`; | ||
return "".concat(serializeComment(entry, "#"), "\n"); | ||
case "GroupComment": | ||
if (state & HAS_ENTRIES) { | ||
return `\n${serializeComment(entry, "##")}\n`; | ||
return "\n".concat(serializeComment(entry, "##"), "\n"); | ||
} | ||
return `${serializeComment(entry, "##")}\n`; | ||
return "".concat(serializeComment(entry, "##"), "\n"); | ||
case "ResourceComment": | ||
if (state & HAS_ENTRIES) { | ||
return `\n${serializeComment(entry, "###")}\n`; | ||
return "\n".concat(serializeComment(entry, "###"), "\n"); | ||
} | ||
return `${serializeComment(entry, "###")}\n`; | ||
return "".concat(serializeComment(entry, "###"), "\n"); | ||
@@ -1943,3 +1941,3 @@ case "Junk": | ||
default: | ||
throw new Error(`Unknown entry type: ${entry.type}`); | ||
throw new Error("Unknown entry type: ".concat(entry.type)); | ||
} | ||
@@ -1952,5 +1950,5 @@ } | ||
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "#"; | ||
const prefixed = comment.content.split("\n").map(line => line.length ? `${prefix} ${line}` : prefix).join("\n"); // Add the trailing newline. | ||
const prefixed = comment.content.split("\n").map(line => line.length ? "".concat(prefix, " ").concat(line) : prefix).join("\n"); // Add the trailing newline. | ||
return `${prefixed}\n`; | ||
return "".concat(prefixed, "\n"); | ||
} | ||
@@ -1969,3 +1967,3 @@ | ||
parts.push(`${message.id.name} =`); | ||
parts.push("".concat(message.id.name, " =")); | ||
@@ -2011,3 +2009,3 @@ if (message.value) { | ||
parts.push(`-${term.id.name} =`); | ||
parts.push("-".concat(term.id.name, " =")); | ||
parts.push(serializePattern(term.value)); | ||
@@ -2044,3 +2042,3 @@ var _iteratorNormalCompletion3 = true; | ||
const value = indent(serializePattern(attribute.value)); | ||
return `\n .${attribute.id.name} =${value}`; | ||
return "\n .".concat(attribute.id.name, " =").concat(value); | ||
} | ||
@@ -2053,6 +2051,6 @@ | ||
if (startOnNewLine) { | ||
return `\n ${indent(content)}`; | ||
return "\n ".concat(indent(content)); | ||
} | ||
return ` ${content}`; | ||
return " ".concat(content); | ||
} | ||
@@ -2069,3 +2067,3 @@ | ||
default: | ||
throw new Error(`Unknown element type: ${element.type}`); | ||
throw new Error("Unknown element type: ".concat(element.type)); | ||
} | ||
@@ -2079,3 +2077,3 @@ } | ||
case "Placeable": | ||
return `{${serializePlaceable(expr)}}`; | ||
return "{".concat(serializePlaceable(expr), "}"); | ||
@@ -2085,6 +2083,6 @@ case "SelectExpression": | ||
// opening and the closing brace. | ||
return `{ ${serializeExpression(expr)}}`; | ||
return "{ ".concat(serializeExpression(expr), "}"); | ||
default: | ||
return `{ ${serializeExpression(expr)} }`; | ||
return "{ ".concat(serializeExpression(expr), " }"); | ||
} | ||
@@ -2096,3 +2094,3 @@ } | ||
case "StringLiteral": | ||
return `"${expr.value}"`; | ||
return "\"".concat(expr.value, "\""); | ||
@@ -2103,10 +2101,10 @@ case "NumberLiteral": | ||
case "VariableReference": | ||
return `$${expr.id.name}`; | ||
return "$".concat(expr.id.name); | ||
case "TermReference": | ||
{ | ||
let out = `-${expr.id.name}`; | ||
let out = "-".concat(expr.id.name); | ||
if (expr.attribute) { | ||
out += `.${expr.attribute.name}`; | ||
out += ".".concat(expr.attribute.name); | ||
} | ||
@@ -2126,3 +2124,3 @@ | ||
if (expr.attribute) { | ||
out += `.${expr.attribute.name}`; | ||
out += ".".concat(expr.attribute.name); | ||
} | ||
@@ -2134,7 +2132,7 @@ | ||
case "FunctionReference": | ||
return `${expr.id.name}${serializeCallArguments(expr.arguments)}`; | ||
return "".concat(expr.id.name).concat(serializeCallArguments(expr.arguments)); | ||
case "SelectExpression": | ||
{ | ||
let out = `${serializeExpression(expr.selector)} ->`; | ||
let out = "".concat(serializeExpression(expr.selector), " ->"); | ||
var _iteratorNormalCompletion4 = true; | ||
@@ -2164,3 +2162,3 @@ var _didIteratorError4 = false; | ||
return `${out}\n`; | ||
return "".concat(out, "\n"); | ||
} | ||
@@ -2172,3 +2170,3 @@ | ||
default: | ||
throw new Error(`Unknown expression type: ${expr.type}`); | ||
throw new Error("Unknown expression type: ".concat(expr.type)); | ||
} | ||
@@ -2182,6 +2180,6 @@ } | ||
if (variant.default) { | ||
return `\n *[${key}]${value}`; | ||
return "\n *[".concat(key, "]").concat(value); | ||
} | ||
return `\n [${key}]${value}`; | ||
return "\n [".concat(key, "]").concat(value); | ||
} | ||
@@ -2194,6 +2192,6 @@ | ||
if (expr.positional.length > 0 && expr.named.length > 0) { | ||
return `(${positional}, ${named})`; | ||
return "(".concat(positional, ", ").concat(named, ")"); | ||
} | ||
return `(${positional || named})`; | ||
return "(".concat(positional || named, ")"); | ||
} | ||
@@ -2203,3 +2201,3 @@ | ||
const value = serializeExpression(arg.value); | ||
return `${arg.name.name}: ${value}`; | ||
return "".concat(arg.name.name, ": ").concat(value); | ||
} | ||
@@ -2216,3 +2214,3 @@ | ||
default: | ||
throw new Error(`Unknown variant key type: ${key.type}`); | ||
throw new Error("Unknown variant key type: ".concat(key.type)); | ||
} | ||
@@ -2236,3 +2234,3 @@ } | ||
const visit = this[`visit${node.type}`] || this.genericVisit; | ||
const visit = this["visit".concat(node.type)] || this.genericVisit; | ||
visit.call(this, node); | ||
@@ -2242,6 +2240,4 @@ } | ||
genericVisit(node) { | ||
var _arr = Object.keys(node); | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
const propname = _arr[_i]; | ||
for (var _i = 0, _Object$keys = Object.keys(node); _i < _Object$keys.length; _i++) { | ||
const propname = _Object$keys[_i]; | ||
this.visit(node[propname]); | ||
@@ -2262,3 +2258,3 @@ } | ||
const visit = this[`visit${node.type}`] || this.genericVisit; | ||
const visit = this["visit".concat(node.type)] || this.genericVisit; | ||
return visit.call(this, node); | ||
@@ -2268,6 +2264,4 @@ } | ||
genericVisit(node) { | ||
var _arr2 = Object.keys(node); | ||
for (var _i2 = 0; _i2 < _arr2.length; _i2++) { | ||
const propname = _arr2[_i2]; | ||
for (var _i2 = 0, _Object$keys2 = Object.keys(node); _i2 < _Object$keys2.length; _i2++) { | ||
const propname = _Object$keys2[_i2]; | ||
const propvalue = node[propname]; | ||
@@ -2323,46 +2317,46 @@ | ||
exports.parse = parse; | ||
exports.serialize = serialize; | ||
exports.lineOffset = lineOffset; | ||
exports.columnOffset = columnOffset; | ||
exports.Annotation = Annotation; | ||
exports.Attribute = Attribute; | ||
exports.BaseComment = BaseComment; | ||
exports.BaseNode = BaseNode; | ||
exports.Resource = Resource; | ||
exports.CallArguments = CallArguments; | ||
exports.Comment = Comment; | ||
exports.Entry = Entry; | ||
exports.Expression = Expression; | ||
exports.FluentParser = FluentParser; | ||
exports.FluentSerializer = FluentSerializer; | ||
exports.FunctionReference = FunctionReference; | ||
exports.GroupComment = GroupComment; | ||
exports.HAS_ENTRIES = HAS_ENTRIES; | ||
exports.Identifier = Identifier; | ||
exports.Junk = Junk; | ||
exports.Literal = Literal; | ||
exports.Message = Message; | ||
exports.Term = Term; | ||
exports.MessageReference = MessageReference; | ||
exports.NamedArgument = NamedArgument; | ||
exports.NumberLiteral = NumberLiteral; | ||
exports.Pattern = Pattern; | ||
exports.PatternElement = PatternElement; | ||
exports.TextElement = TextElement; | ||
exports.Placeable = Placeable; | ||
exports.Expression = Expression; | ||
exports.Literal = Literal; | ||
exports.Resource = Resource; | ||
exports.ResourceComment = ResourceComment; | ||
exports.SelectExpression = SelectExpression; | ||
exports.Span = Span; | ||
exports.StringLiteral = StringLiteral; | ||
exports.NumberLiteral = NumberLiteral; | ||
exports.MessageReference = MessageReference; | ||
exports.Term = Term; | ||
exports.TermReference = TermReference; | ||
exports.TextElement = TextElement; | ||
exports.Transformer = Transformer; | ||
exports.VariableReference = VariableReference; | ||
exports.FunctionReference = FunctionReference; | ||
exports.SelectExpression = SelectExpression; | ||
exports.CallArguments = CallArguments; | ||
exports.Attribute = Attribute; | ||
exports.Variant = Variant; | ||
exports.NamedArgument = NamedArgument; | ||
exports.Identifier = Identifier; | ||
exports.BaseComment = BaseComment; | ||
exports.Comment = Comment; | ||
exports.GroupComment = GroupComment; | ||
exports.ResourceComment = ResourceComment; | ||
exports.Junk = Junk; | ||
exports.Span = Span; | ||
exports.Annotation = Annotation; | ||
exports.FluentParser = FluentParser; | ||
exports.HAS_ENTRIES = HAS_ENTRIES; | ||
exports.FluentSerializer = FluentSerializer; | ||
exports.Visitor = Visitor; | ||
exports.columnOffset = columnOffset; | ||
exports.lineOffset = lineOffset; | ||
exports.parse = parse; | ||
exports.serialize = serialize; | ||
exports.serializeExpression = serializeExpression; | ||
exports.serializeVariantKey = serializeVariantKey; | ||
exports.Visitor = Visitor; | ||
exports.Transformer = Transformer; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
})); |
@@ -1,7 +0,7 @@ | ||
/* fluent-syntax@0.12.0 */ | ||
/* fluent-syntax@0.13.0 */ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define('fluent-syntax', ['exports'], factory) : | ||
(factory((global.FluentSyntax = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
(global = global || self, factory(global.FluentSyntax = {})); | ||
}(this, function (exports) { 'use strict'; | ||
@@ -997,15 +997,15 @@ /* | ||
let Comment$$1; | ||
let Comment$1; | ||
switch (level) { | ||
case 0: | ||
Comment$$1 = Comment; | ||
Comment$1 = Comment; | ||
break; | ||
case 1: | ||
Comment$$1 = GroupComment; | ||
Comment$1 = GroupComment; | ||
break; | ||
case 2: | ||
Comment$$1 = ResourceComment; | ||
Comment$1 = ResourceComment; | ||
break; | ||
} | ||
return new Comment$$1(content); | ||
return new Comment$1(content); | ||
} | ||
@@ -1221,3 +1221,3 @@ | ||
} else { | ||
var commonIndentLength = Infinity; | ||
commonIndentLength = Infinity; | ||
} | ||
@@ -1928,46 +1928,46 @@ | ||
exports.parse = parse; | ||
exports.serialize = serialize; | ||
exports.lineOffset = lineOffset; | ||
exports.columnOffset = columnOffset; | ||
exports.Annotation = Annotation; | ||
exports.Attribute = Attribute; | ||
exports.BaseComment = BaseComment; | ||
exports.BaseNode = BaseNode; | ||
exports.Resource = Resource; | ||
exports.CallArguments = CallArguments; | ||
exports.Comment = Comment; | ||
exports.Entry = Entry; | ||
exports.Expression = Expression; | ||
exports.FluentParser = FluentParser; | ||
exports.FluentSerializer = FluentSerializer; | ||
exports.FunctionReference = FunctionReference; | ||
exports.GroupComment = GroupComment; | ||
exports.HAS_ENTRIES = HAS_ENTRIES; | ||
exports.Identifier = Identifier; | ||
exports.Junk = Junk; | ||
exports.Literal = Literal; | ||
exports.Message = Message; | ||
exports.Term = Term; | ||
exports.MessageReference = MessageReference; | ||
exports.NamedArgument = NamedArgument; | ||
exports.NumberLiteral = NumberLiteral; | ||
exports.Pattern = Pattern; | ||
exports.PatternElement = PatternElement; | ||
exports.TextElement = TextElement; | ||
exports.Placeable = Placeable; | ||
exports.Expression = Expression; | ||
exports.Literal = Literal; | ||
exports.Resource = Resource; | ||
exports.ResourceComment = ResourceComment; | ||
exports.SelectExpression = SelectExpression; | ||
exports.Span = Span; | ||
exports.StringLiteral = StringLiteral; | ||
exports.NumberLiteral = NumberLiteral; | ||
exports.MessageReference = MessageReference; | ||
exports.Term = Term; | ||
exports.TermReference = TermReference; | ||
exports.TextElement = TextElement; | ||
exports.Transformer = Transformer; | ||
exports.VariableReference = VariableReference; | ||
exports.FunctionReference = FunctionReference; | ||
exports.SelectExpression = SelectExpression; | ||
exports.CallArguments = CallArguments; | ||
exports.Attribute = Attribute; | ||
exports.Variant = Variant; | ||
exports.NamedArgument = NamedArgument; | ||
exports.Identifier = Identifier; | ||
exports.BaseComment = BaseComment; | ||
exports.Comment = Comment; | ||
exports.GroupComment = GroupComment; | ||
exports.ResourceComment = ResourceComment; | ||
exports.Junk = Junk; | ||
exports.Span = Span; | ||
exports.Annotation = Annotation; | ||
exports.FluentParser = FluentParser; | ||
exports.HAS_ENTRIES = HAS_ENTRIES; | ||
exports.FluentSerializer = FluentSerializer; | ||
exports.Visitor = Visitor; | ||
exports.columnOffset = columnOffset; | ||
exports.lineOffset = lineOffset; | ||
exports.parse = parse; | ||
exports.serialize = serialize; | ||
exports.serializeExpression = serializeExpression; | ||
exports.serializeVariantKey = serializeVariantKey; | ||
exports.Visitor = Visitor; | ||
exports.Transformer = Transformer; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
})); |
{ | ||
"name": "fluent-syntax", | ||
"description": "AST and parser for Fluent", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"homepage": "http://projectfluent.org", | ||
@@ -6,0 +6,0 @@ "author": "Mozilla <l10n-drivers@mozilla.org>", |
@@ -433,3 +433,3 @@ /* eslint no-magic-numbers: [0] */ | ||
} else { | ||
var commonIndentLength = Infinity; | ||
commonIndentLength = Infinity; | ||
} | ||
@@ -436,0 +436,0 @@ |
168033
15
5133