Skip to content

Remove Fluent 0.4 syntax support from fluent.syntax #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 3 additions & 72 deletions fluent.syntax/fluent/syntax/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,7 @@ def parse(self, source):
# clear it.
last_comment = None

if isinstance(entry, ast.Comment) \
and ps.last_comment_zero_four_syntax \
and len(entries) == 0:
comment = ast.ResourceComment(entry.content)
comment.span = entry.span
entries.append(comment)
else:
entries.append(entry)

ps.last_comment_zero_four_syntax = False
entries.append(entry)

res = ast.Resource(entries)

Expand Down Expand Up @@ -131,12 +122,6 @@ def get_entry(self, ps):
if ps.current_char == '#':
return self.get_comment(ps)

if ps.current_char == '/':
return self.get_zero_four_style_comment(ps)

if ps.current_char == '[':
return self.get_group_comment_from_section(ps)

if ps.current_char == '-':
return self.get_term(ps)

Expand All @@ -145,39 +130,6 @@ def get_entry(self, ps):

raise ParseError('E0002')

@with_span
def get_zero_four_style_comment(self, ps):
ps.expect_char('/')
ps.expect_char('/')
ps.take_char(lambda x: x == ' ')

content = ''

while True:
ch = ps.take_char(lambda x: x != EOL)
while ch:
content += ch
ch = ps.take_char(lambda x: x != EOL)

if ps.is_next_line_zero_four_comment():
content += ps.current_char
ps.next()
ps.expect_char('/')
ps.expect_char('/')
ps.take_char(lambda x: x == ' ')
else:
break

# Comments followed by Sections become GroupComments.
if ps.peek() == '[':
ps.skip_to_peek()
self.get_group_comment_from_section(ps)
return ast.GroupComment(content)

ps.reset_peek()
ps.last_comment_zero_four_syntax = True
return ast.Comment(content)

@with_span
def get_comment(self, ps):
# 0 - comment
Expand Down Expand Up @@ -216,34 +168,13 @@ def get_comment(self, ps):
elif level == 2:
return ast.ResourceComment(content)

@with_span
def get_group_comment_from_section(self, ps):
def until_closing_bracket_or_eol(ch):
return ch not in (']', EOL)

ps.expect_char('[')
ps.expect_char('[')
while ps.take_char(until_closing_bracket_or_eol):
pass
ps.expect_char(']')
ps.expect_char(']')

# A Section without a comment is like an empty Group Comment.
# Semantically it ends the previous group and starts a new one.
return ast.GroupComment('')

@with_span
def get_message(self, ps):
id = self.get_identifier(ps)
ps.skip_blank_inline()
ps.expect_char('=')

# XXX Syntax 0.4 compat
if ps.current_char == '=':
ps.next()
value = self.maybe_get_pattern(ps)
else:
value = None

value = self.maybe_get_pattern(ps)
attrs = self.get_attributes(ps)

if value is None and len(attrs) == 0:
Expand Down
9 changes: 0 additions & 9 deletions fluent.syntax/fluent/syntax/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def skip_to_peek(self):


class FluentParserStream(ParserStream):
last_comment_zero_four_syntax = False

def peek_blank_inline(self):
start = self.index + self.peek_offset
Expand Down Expand Up @@ -186,14 +185,6 @@ def is_value_continuation(self):

return False

def is_next_line_zero_four_comment(self):
if self.current_peek != EOL:
return False

is_comment = (self.peek(), self.peek()) == ('/', '/')
self.reset_peek()
return is_comment

# -1 - any
# 0 - comment
# 1 - group comment
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo
# ~ERROR E0005, pos 3, args "foo"
# ~ERROR E0003, pos 3, args "="
Loading