Skip to content

Commit b784927

Browse files
committed
Merge branch 'namespace_packages' into implement_format
2 parents 9d84579 + ace6679 commit b784927

209 files changed

Lines changed: 9514 additions & 585 deletions

File tree

Some content is hidden

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

.gitattributes

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
tests/syntax/fixtures_reference/crlf.ftl eol=crlf
2-
tests/syntax/fixtures_structure/crlf.ftl eol=crlf
1+
fluent-syntax/tests/syntax/fixtures_reference/crlf.ftl eol=crlf
2+
fluent-syntax/tests/syntax/fixtures_reference/cr.ftl eol=cr
3+
fluent-syntax/tests/syntax/fixtures_structure/crlf.ftl eol=crlf

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ python:
77
- "pypy"
88
- "pypy3"
99
- "nightly"
10+
env:
11+
- PACKAGE=fluent-syntax
1012
install: pip install tox-travis
11-
script: tox
13+
script: cd $PACKAGE; tox
1214
notifications:
1315
irc:
1416
channels:

CHANGELOG.md renamed to fluent-syntax/CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,62 @@
11
# Changelog
22

3+
## fluent-syntax 0.10.0 (December 13, 2018)
4+
5+
This release brings support for version 0.8 of the Fluent Syntax spec. The API
6+
remains unchanged. Files written in valid Syntax 0.7 may not parse correctly in
7+
this release. See the summary of backwards-incompatible changes below.
8+
9+
- Implement Fluent Syntax 0.8. (#303)
10+
11+
This is only a quick summary of the spec changes in Syntax 0.8. Consult the
12+
full [changelog][chlog0.8] for details.
13+
14+
[chlog0.8]: https://github.com/projectfluent/fluent/releases/tag/v0.8.0
15+
16+
In multiline `Patterns`, all common indent is now removed from each
17+
indented line in the final value of the pattern.
18+
19+
```properties
20+
multiline =
21+
This message has 2 spaces of indent
22+
on the second line of its value.
23+
```
24+
25+
`Terms` can now be parameterized via the call expression syntax.
26+
27+
```properties
28+
# A parametrized Term with a Pattern as a value.
29+
-thing = { $article ->
30+
*[definite] the thing
31+
[indefinite] a thing
32+
}
33+
34+
this = This is { -thing(article: "indefinite") }.
35+
```
36+
37+
`VariantLists` are now deprecated and will be removed from the Syntax
38+
before version 1.0.
39+
40+
All escapes sequences can only be used in `StringLiterals` now (see below).
41+
`\UHHHHHH` is a new escape sequence format suitable for codepoints above
42+
U+FFFF, e.g. `{"\U01F602"}`.
43+
44+
### Backward-incompatible changes:
45+
46+
- The backslash character (`\`) is now considered a regular character in
47+
`TextElements`. It's no longer possible to use escape sequences in
48+
`TextElements`. Please use `StringLiterals` instead, e.g. `{"\u00A0"}`.
49+
- The closing curly brace character (`}`) is not allowed in `TextElements`
50+
now. Please use `StringLiterals` instead: `{"}"}`.
51+
- `StringLiteral.value` was changed to store the unescaped ("cooked") value.
52+
`StringLiteral.raw` has been added to store the raw value.
53+
- The AST of `CallExpressions` was changed to better accommodate the
54+
introduction of parameterized `Terms`. The `Function` AST node has been
55+
replaced by the `FunctionReference` node.
56+
- The leading dash (`-`) is no longer part of the `Identifier` node in
57+
`Terms` and `TermReferences`.
58+
59+
360
## fluent 0.9.0 (October 23, 2018)
461
562
This release brings support for version 0.7 of the Fluent Syntax spec. The
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import json
44

55

6-
def to_json(value):
6+
def to_json(value, fn=None):
77
if isinstance(value, BaseNode):
8-
return value.to_json()
8+
return value.to_json(fn)
99
if isinstance(value, list):
10-
return list(map(to_json, value))
10+
return list(to_json(item, fn) for item in value)
1111
if isinstance(value, tuple):
12-
return list(map(to_json, value))
12+
return list(to_json(item, fn) for item in value)
1313
else:
1414
return value
1515

@@ -119,15 +119,15 @@ def equals(self, other, ignored_fields=['span']):
119119

120120
return True
121121

122-
def to_json(self):
122+
def to_json(self, fn=None):
123123
obj = {
124-
name: to_json(value)
124+
name: to_json(value, fn)
125125
for name, value in vars(self).items()
126126
}
127127
obj.update(
128128
{'type': self.__class__.__name__}
129129
)
130-
return obj
130+
return fn(obj) if fn else obj
131131

132132
def __str__(self):
133133
return json.dumps(self.to_json())
@@ -207,8 +207,9 @@ class Expression(SyntaxNode):
207207

208208

209209
class StringLiteral(Expression):
210-
def __init__(self, value, **kwargs):
210+
def __init__(self, raw, value, **kwargs):
211211
super(StringLiteral, self).__init__(**kwargs)
212+
self.raw = raw
212213
self.value = value
213214

214215

@@ -236,6 +237,12 @@ def __init__(self, id, **kwargs):
236237
self.id = id
237238

238239

240+
class FunctionReference(Expression):
241+
def __init__(self, id, **kwargs):
242+
super(FunctionReference, self).__init__(**kwargs)
243+
self.id = id
244+
245+
239246
class SelectExpression(Expression):
240247
def __init__(self, selector, variants, **kwargs):
241248
super(SelectExpression, self).__init__(**kwargs)
@@ -324,11 +331,6 @@ def __init__(self, content=None, **kwargs):
324331
super(ResourceComment, self).__init__(content, **kwargs)
325332

326333

327-
class Function(Identifier):
328-
def __init__(self, name, **kwargs):
329-
super(Function, self).__init__(name, **kwargs)
330-
331-
332334
class Junk(SyntaxNode):
333335
def __init__(self, content=None, annotations=None, **kwargs):
334336
super(Junk, self).__init__(**kwargs)
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ def get_error_message(code, args):
2121
msg = 'Expected message "{}" to have a value or attributes'
2222
return msg.format(args[0])
2323
if code == 'E0006':
24-
msg = 'Expected term "{}" to have a value'
24+
msg = 'Expected term "-{}" to have a value'
2525
return msg.format(args[0])
2626
if code == 'E0007':
2727
return 'Keyword cannot end with a whitespace'
2828
if code == 'E0008':
29-
return 'The callee has to be a simple, upper-case identifier'
29+
return 'The callee has to be an upper-case identifier or a term'
3030
if code == 'E0009':
3131
return 'The key has to be a simple identifier'
3232
if code == 'E0010':
@@ -44,7 +44,7 @@ def get_error_message(code, args):
4444
if code == 'E0016':
4545
return 'Message references cannot be used as selectors'
4646
if code == 'E0017':
47-
return 'Variants cannot be used as selectors'
47+
return 'Terms cannot be used as selectors'
4848
if code == 'E0018':
4949
return 'Attributes of messages cannot be used as selectors'
5050
if code == 'E0019':
@@ -55,12 +55,14 @@ def get_error_message(code, args):
5555
return 'Positional arguments must not follow named arguments'
5656
if code == 'E0022':
5757
return 'Named arguments must be unique'
58-
if code == 'E0023':
59-
return 'VariantLists are only allowed inside of other VariantLists.'
6058
if code == 'E0024':
6159
return 'Cannot access variants of a message.'
6260
if code == 'E0025':
63-
return 'Unknown escape sequence: {}'.format(args[0])
61+
return 'Unknown escape sequence: \\{}.'.format(args[0])
6462
if code == 'E0026':
6563
return 'Invalid Unicode escape sequence: {}'.format(args[0])
64+
if code == 'E0027':
65+
return 'Unbalanced closing brace in TextElement.'
66+
if code == 'E0028':
67+
return 'Expected an inline expression'
6668
return code

0 commit comments

Comments
 (0)