-
Notifications
You must be signed in to change notification settings - Fork 28
Support Syntax 0.7 #76
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
Conversation
ps.skip_inline_ws() | ||
|
||
while ps.take_char(until_closing_bracket_or_eol): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this PR removes VariantName
, we need a different way to skip 0.4 section titles. At first I thought about using a regex, but using the take_char
method of FTLParseStream
is more idiomatic to the rest of this file and also moves the cursor.
@Pike Do you want to review this? It's 99% simple port of the JS version, and 1% of 0.4 compatibility. I added a short readme in |
I'll look into this. |
Thanks. I have one more commit, a port of projectfluent/fluent.js@b09a623, which I'll push once you're done with the review. It moves things around a bit; it would make the review hard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks OK, but we need a better solution for Windows line endings.
Seems that they don't work at all right now? Can we move that into a different issue/release?
fluent/syntax/parser.py
Outdated
@@ -30,15 +30,15 @@ def __init__(self, with_spans=True): | |||
self.with_spans = with_spans | |||
|
|||
def parse(self, source): | |||
ps = FTLParserStream(source) | |||
ps.skip_blank_lines() | |||
ps = FTLParserStream(source.replace('\r\n', '\n')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will invalidate all spans including error positions for files with Windows line endings.
Looking at the js side of things, that doesn't handle Windows line endings at all right now?
I think we should use the algorithm we have in the reference parser to fix this issue, i.e., normalize newlines on text node creation.
fluent/syntax/parser.py
Outdated
@@ -92,15 +92,15 @@ def parse_entry(self, source): | |||
Preceding comments are ignored unless they contain syntax errors | |||
themselves, in which case Junk for the invalid comment is returned. | |||
""" | |||
ps = FTLParserStream(source) | |||
ps.skip_blank_lines() | |||
ps = FTLParserStream(source.replace('\r\n', '\n')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here.
I'd like to see the disambiguation between a failed The key lines would be which used to return I ran the branch through compare-locales tests which pass, and also recreated a healthy amount of gecko-strings quarantine with the branch which resulted in the same hashes that flod generated with current master. |
Port of projectfluent/fluent.js#287