Skip to content
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

Implement Syntax 0.8, part3 #310

Merged
merged 3 commits into from
Nov 29, 2018
Merged

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Nov 22, 2018

Depends on #309.

@stasm
Copy link
Contributor Author

stasm commented Nov 26, 2018

@zbraniecki This PR is about two simple changes but it looks complex because it depends on #309, which is also included here for now. Once #309 lands, this will be easy to review. Thanks!

@stasm stasm mentioned this pull request Nov 27, 2018
15 tasks
@stasm
Copy link
Contributor Author

stasm commented Nov 28, 2018

This is now ready for the review.

Copy link
Collaborator

@zbraniecki zbraniecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wide this looks good.

I must say that reading it again made me realize that I think I struggle with why are we storing the unescaped version of the string in the AST at all, it seems to me that it should be resolvers job, and the parse/ast/serialize cycle should treat escaped string literals as such.

Have we considered storing only what we now have in raw field? If we did and decided somehow against it, maybe we should at least reverse the fields and store what's in raw as the actual value, and then what's currently in value as an implementation-specific optimization as encoded_value.
In particular, Rust parser may want to skip the encoded_value in AST to keep it allocation free.

@stasm
Copy link
Contributor Author

stasm commented Nov 29, 2018

Thanks for the review.

I must say that reading it again made me realize that I think I struggle with why are we storing the unescaped version of the string in the AST at all, it seems to me that it should be resolvers job, and the parse/ast/serialize cycle should treat escaped string literals as such.

Why do you think it should be the resolver's job? In the runtime implementation in fluent.js we unescape during parse-time. From what I've seen, it's a common practice in many languages. Do you think we should move this logic into the resolver?

This approach has the added benefit of standardizing how the escaping mechanism works exactly on the parser level, rather than leaving it up to the (currently unspecified) runtime.

The parser-serializer roundtrip continues to use the raw escaped value.

Have we considered storing only what we now have in raw field? If we did and decided somehow against it, maybe we should at least reverse the fields and store what's in raw as the actual value, and then what's currently in value as an implementation-specific optimization as encoded_value.

projectfluent/fluent#195 has the discussion and the details on this design. if you have ideas on how to improve it, please open a new issue. I'd like to avoid going back at this point in order to streamline the effort of implementing Syntax 0.8. A new issue can be discussed and then implemented independently of this PR.

In particular, Rust parser may want to skip the encoded_value in AST to keep it allocation free.

Just skip value, then?

@stasm stasm merged commit 271b7ec into projectfluent:zeroeight Nov 29, 2018
@stasm stasm deleted the zeroeight-part3 branch November 29, 2018 08:51
@zbraniecki
Copy link
Collaborator

In the runtime implementation in fluent.js we unescape during parse-time.

That's reasonable. We parse exclusively to display there, and we build whatever works best for display. AST is meant to store semantic representation of the source.

Do you think we should move this logic into the resolver?

No.

The parser-serializer roundtrip continues to use the raw escaped value.

Which makes me think that maybe this should be the value field.

if you have ideas on how to improve it, please open a new issue.

Will do! I don't think it should block :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants