Skip to content

Commit 277a134

Browse files
author
Zibi Braniecki
committed
Fix a couple AST mistakes caught while porting the parser to Rust
1 parent b9855a9 commit 277a134

10 files changed

+17
-18
lines changed

fluent-syntax/src/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function getErrorMessage(code, args) {
2323
}
2424
case 'E0005': {
2525
const [id] = args;
26-
return `Expected entry "${id}" to have a value, attributes or tags`;
26+
return `Expected entry "${id}" to have a value or attributes`;
2727
}
2828
case 'E0006': {
2929
const [field] = args;

fluent-syntax/src/ftlstream.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class FTLParserStream extends ParserStream {
226226
this.next();
227227
return ret;
228228
}
229-
throw new ParseError('E0004', 'a-zA-Z');
229+
throw new ParseError('E0004', 'a-zA-Z_');
230230
}
231231

232232
takeIDChar() {
@@ -243,15 +243,11 @@ export class FTLParserStream extends ParserStream {
243243

244244
takeSymbChar() {
245245
const closure = ch => {
246-
if (ch === undefined) {
247-
return false;
248-
}
249-
250246
const cc = ch.charCodeAt(0);
251247
return ((cc >= 97 && cc <= 122) || // a-z
252248
(cc >= 65 && cc <= 90) || // A-Z
253249
(cc >= 48 && cc <= 57) || // 0-9
254-
cc === 95 || cc === 45 || cc === 32); // _-
250+
cc === 95 || cc === 45 || cc === 32); // _-<space>
255251
};
256252

257253
return this.takeChar(closure);

fluent-syntax/src/parser.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export default class FluentParser {
153153

154154
ps.next();
155155

156-
if (ps.current() === '/') {
156+
if (ps.currentIs('/')) {
157157
content += '\n';
158158
ps.next();
159159
ps.expectChar('/');
@@ -212,7 +212,7 @@ export default class FluentParser {
212212
tags = this.getTags(ps);
213213
}
214214

215-
if (pattern === undefined && attrs === undefined && tags === undefined) {
215+
if (pattern === undefined && attrs === undefined) {
216216
throw new ParseError('E0005', id.name);
217217
}
218218

@@ -566,7 +566,10 @@ export default class FluentParser {
566566

567567
ps.expectChar(')');
568568

569-
return new AST.CallExpression(literal.id, args);
569+
return new AST.CallExpression(
570+
new AST.Function(literal.id.name),
571+
args
572+
);
570573
}
571574

572575
return literal;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
key = { foo.23 }
22
3-
//~ ERROR E0004, pos 12, args "a-zA-Z"
3+
//~ ERROR E0004, pos 12, args "a-zA-Z_"
44

55
key = { foo. }
66
7-
//~ ERROR E0004, pos 31, args "a-zA-Z"
7+
//~ ERROR E0004, pos 31, args "a-zA-Z_"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
key = Value
22
.2 = Foo
3-
//~ ERROR E0004, pos 17, args "a-zA-Z"
3+
//~ ERROR E0004, pos 17, args "a-zA-Z_"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
bar = Bar {
2-
//~ ERROR E0004, pos 11, args "a-zA-Z"
2+
//~ ERROR E0004, pos 11, args "a-zA-Z_"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
key = { $foo ->
22
*[
3-
//~ ERROR E0004, pos 22, args "a-zA-Z"
3+
//~ ERROR E0004, pos 22, args "a-zA-Z_"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
key = { foo[] }
2-
//~ ERROR E0004, pos 12, args "a-zA-Z"
2+
//~ ERROR E0004, pos 12, args "a-zA-Z_"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
key = {
22
*[one] Value
33
}
4-
//~ ERROR E0004, pos 7, args "a-zA-Z"
4+
//~ ERROR E0004, pos 7, args "a-zA-Z_"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
key = {
22
*[ one] Foo
33
}
4-
//~ ERROR E0004, pos 18, args "a-zA-Z"
4+
//~ ERROR E0004, pos 18, args "a-zA-Z_"

0 commit comments

Comments
 (0)