Skip to content

Commit bdbb195

Browse files
authored
Merge pull request #317 from projectfluent/zeroeight
Implement Syntax 0.8
2 parents 6edf276 + a1e4230 commit bdbb195

File tree

121 files changed

+5475
-1501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+5475
-1501
lines changed

eslint_src.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@
3232
],
3333
"no-implied-eval": 2,
3434
"no-loop-func": 2,
35-
"no-magic-numbers": [
36-
1,
37-
{
38-
"ignore": [
39-
-1,
40-
0,
41-
1,
42-
2
43-
]
44-
}
45-
],
4635
"no-useless-call": 2,
4736
"no-useless-concat": 2,
4837
"no-delete-var": 2,
@@ -59,7 +48,6 @@
5948
"no-extend-native": 2,
6049
"no-global-assign": 2,
6150
"no-extra-bind": 2,
62-
"no-redeclare": 2,
6351
"array-bracket-spacing": 2,
6452
"brace-style": [
6553
1,

fluent-syntax/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
test/fixtures_reference/crlf.ftl eol=crlf
2+
test/fixtures_reference/cr.ftl eol=cr
23
test/fixtures_structure/crlf.ftl eol=crlf

fluent-syntax/src/ast.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ export class Placeable extends PatternElement {
9696
export class Expression extends SyntaxNode {}
9797

9898
export class StringLiteral extends Expression {
99-
constructor(value) {
99+
constructor(raw, value) {
100100
super();
101101
this.type = "StringLiteral";
102+
this.raw = raw;
102103
this.value = value;
103104
}
104105
}
@@ -135,6 +136,14 @@ export class VariableReference extends Expression {
135136
}
136137
}
137138

139+
export class FunctionReference extends Expression {
140+
constructor(id) {
141+
super();
142+
this.type = "FunctionReference";
143+
this.id = id;
144+
}
145+
}
146+
138147
export class SelectExpression extends Expression {
139148
constructor(selector, variants) {
140149
super();
@@ -236,13 +245,6 @@ export class ResourceComment extends BaseComment {
236245
}
237246
}
238247

239-
export class Function extends Identifier {
240-
constructor(name) {
241-
super(name);
242-
this.type = "Function";
243-
}
244-
}
245-
246248
export class Junk extends SyntaxNode {
247249
constructor(content) {
248250
super();

fluent-syntax/src/errors.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ function getErrorMessage(code, args) {
2828
}
2929
case "E0006": {
3030
const [id] = args;
31-
return `Expected term "${id}" to have a value`;
31+
return `Expected term "-${id}" to have a value`;
3232
}
3333
case "E0007":
3434
return "Keyword cannot end with a whitespace";
3535
case "E0008":
36-
return "The callee has to be a simple, upper-case identifier";
36+
return "The callee has to be an upper-case identifier or a term";
3737
case "E0009":
3838
return "The key has to be a simple identifier";
3939
case "E0010":
@@ -51,7 +51,7 @@ function getErrorMessage(code, args) {
5151
case "E0016":
5252
return "Message references cannot be used as selectors";
5353
case "E0017":
54-
return "Variants cannot be used as selectors";
54+
return "Terms cannot be used as selectors";
5555
case "E0018":
5656
return "Attributes of messages cannot be used as selectors";
5757
case "E0019":
@@ -62,18 +62,20 @@ function getErrorMessage(code, args) {
6262
return "Positional arguments must not follow named arguments";
6363
case "E0022":
6464
return "Named arguments must be unique";
65-
case "E0023":
66-
return "VariantLists are only allowed inside of other VariantLists.";
6765
case "E0024":
6866
return "Cannot access variants of a message.";
6967
case "E0025": {
7068
const [char] = args;
7169
return `Unknown escape sequence: \\${char}.`;
7270
}
7371
case "E0026": {
74-
const [char] = args;
75-
return `Invalid Unicode escape sequence: \\u${char}.`;
72+
const [sequence] = args;
73+
return `Invalid Unicode escape sequence: ${sequence}.`;
7674
}
75+
case "E0027":
76+
return "Unbalanced closing brace in TextElement.";
77+
case "E0028":
78+
return "Expected an inline expression";
7779
default:
7880
return code;
7981
}

0 commit comments

Comments
 (0)