Skip to content

Commit 6a04f74

Browse files
committed
Remove Comment.zero_four_style from the AST
1 parent ed746d7 commit 6a04f74

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

fluent/syntax/ftlstream.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88

99
class FTLParserStream(ParserStream):
10+
last_comment_zero_four_syntax = False
11+
1012
def peek_inline_ws(self):
1113
ch = self.current_peek()
1214
while ch:

fluent/syntax/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ def parse(self, source):
4747
continue
4848

4949
if isinstance(entry, ast.Comment) \
50-
and hasattr(entry, "zero_four_style") and len(entries) == 0:
50+
and ps.last_comment_zero_four_syntax \
51+
and len(entries) == 0:
5152
comment = ast.ResourceComment(entry.content)
5253
comment.span = entry.span
5354
entries.append(comment)
5455
else:
5556
entries.append(entry)
5657

58+
ps.last_comment_zero_four_syntax = False
59+
5760
ps.skip_inline_ws()
5861
ps.skip_blank_lines()
5962

@@ -138,7 +141,7 @@ def get_zero_four_style_comment(self, ps):
138141
break
139142

140143
comment = ast.Comment(content)
141-
comment.zero_four_style = True
144+
ps.last_comment_zero_four_syntax = True
142145
return comment
143146

144147
@with_span

tests/syntax/fixtures_structure/standalone_comment.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"type": "Comment",
4545
"annotations": [],
4646
"content": "This is a standalone comment",
47-
"zero_four_style": true,
4847
"span": {
4948
"type": "Span",
5049
"start": 13,

tests/syntax/test_ast_json.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def test_simple_resource(self):
2929

3030
def test_complex_resource(self):
3131
input = """\
32-
// A Resource comment
32+
### A Resource comment
3333
34-
// A comment about shared-photos
34+
# A comment about shared-photos
3535
shared-photos =
3636
{ $user_name } { $photo_count ->
3737
[0] hasn't added any photos yet
@@ -40,10 +40,9 @@ def test_complex_resource(self):
4040
}.
4141
4242
43-
// A Section comment
44-
[[ Section ]]
43+
## A Section comment
4544
46-
// A comment about liked-comment
45+
// A Syntax 0.4 comment about liked-comment
4746
liked-comment =
4847
{ $user_name } liked your comment on { $user_gender ->
4948
[male] his

0 commit comments

Comments
 (0)