Skip to content

Commit a76040a

Browse files
unclenachoduhstasm
authored andcommitted
Remove VariantName
1 parent ce7efd7 commit a76040a

File tree

5 files changed

+8
-47
lines changed

5 files changed

+8
-47
lines changed

fluent/syntax/ast.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,6 @@ def __init__(self, name, **kwargs):
303303
self.name = name
304304

305305

306-
class VariantName(Identifier):
307-
def __init__(self, name, **kwargs):
308-
super(VariantName, self).__init__(name, **kwargs)
309-
310-
311306
class BaseComment(Entry):
312307
def __init__(self, content=None, **kwargs):
313308
super(BaseComment, self).__init__(**kwargs)

fluent/syntax/ftlstream.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,6 @@ def closure(ch):
263263
cc == 95 or cc == 45)
264264
return self.take_char(closure)
265265

266-
def take_variant_name_char(self):
267-
def closure(ch):
268-
if ch is None:
269-
return False
270-
cc = ord(ch)
271-
return (cc >= 97 and cc <= 122) or \
272-
(cc >= 65 and cc <= 90) or \
273-
(cc >= 48 and cc <= 57) or \
274-
cc == 95 or cc == 45 or cc == 32
275-
return self.take_char(closure)
276-
277266
def take_digit(self):
278267
def closure(ch):
279268
cc = ord(ch)

fluent/syntax/parser.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,13 @@ def get_comment(self, ps):
217217

218218
@with_span
219219
def get_group_comment_from_section(self, ps):
220+
def until_closing_bracket_or_eol(ch):
221+
return ch not in (']', '\n')
222+
220223
ps.expect_char('[')
221224
ps.expect_char('[')
222-
223-
ps.skip_blank_inline()
224-
225-
self.get_variant_name(ps)
226-
227-
ps.skip_blank_inline()
228-
225+
while ps.take_char(until_closing_bracket_or_eol):
226+
pass
229227
ps.expect_char(']')
230228
ps.expect_char(']')
231229

@@ -328,7 +326,7 @@ def get_variant_key(self, ps):
328326
if ((cc >= 48 and cc <= 57) or cc == 45): # 0-9, -
329327
return self.get_number(ps)
330328

331-
return self.get_variant_name(ps)
329+
return self.get_identifier(ps)
332330

333331
@with_span
334332
def get_variant(self, ps, has_default):
@@ -376,18 +374,6 @@ def get_variants(self, ps):
376374

377375
return variants
378376

379-
@with_span
380-
def get_variant_name(self, ps):
381-
name = ps.take_id_start()
382-
while True:
383-
ch = ps.take_variant_name_char()
384-
if ch:
385-
name += ch
386-
else:
387-
break
388-
389-
return ast.VariantName(name.rstrip(' \t\n\r'))
390-
391377
def get_digits(self, ps):
392378
num = ''
393379

fluent/syntax/serializer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ def serialize_variant_name(symbol):
276276

277277

278278
def serialize_variant_key(key):
279-
if isinstance(key, ast.VariantName):
280-
return serialize_variant_name(key)
279+
if isinstance(key, ast.Identifier):
280+
return serialize_identifier(key)
281281
if isinstance(key, ast.NumberLiteral):
282282
return serialize_number_literal(key)
283283
raise Exception('Unknown variant key type: {}'.format(type(key)))

tests/syntax/test_serializer.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,6 @@ def test_variant_multiline_first_inline(self):
269269
"""
270270
self.assertEqual(self.pretty_ftl(input), dedent_ftl(output))
271271

272-
def test_variant_key_words(self):
273-
input = """\
274-
foo =
275-
{ $sel ->
276-
*[a b c] A B C
277-
}
278-
"""
279-
self.assertEqual(self.pretty_ftl(input), dedent_ftl(input))
280-
281272
def test_variant_key_number(self):
282273
input = """\
283274
foo =

0 commit comments

Comments
 (0)