Skip to content

Commit e009457

Browse files
committed
Implement Syntax 0.8
1 parent 6f3b911 commit e009457

39 files changed

+2133
-506
lines changed

.gitattributes

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

fluent/syntax/ast.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

fluent/syntax/errors.py

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)