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

Add private messages #130

Merged
merged 3 commits into from
Jan 23, 2018
Merged

Add private messages #130

merged 3 commits into from
Jan 23, 2018

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Jan 22, 2018

@@ -45,6 +46,14 @@ function getErrorMessage(code, args) {
return 'Expected literal';
case 'E0015':
return 'Only one variant can be marked as default (*)';
case 'E0016':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fluent-rs uses smaller errors numbers for these because it seems to be missing a few earlier ones.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to make error naming part of the developer productivity review after 0.7.

@@ -693,17 +718,25 @@ export default class FluentParser {
throw new ParseError('E0014');
}

if (ch === '$') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the $ check to the top as this will likely be the most common literal.

@@ -28,7 +28,7 @@ export default class FluentSerializer {
}

for (const entry of resource.body) {
if (entry.types !== 'Junk' || this.withJunk) {
if (entry.type !== 'Junk' || this.withJunk) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A nasty typo but fortunately didn't impact many tests. It made the serializer serialize Junks verbatim as they appear in the parsed text. Input magically always matched the output...

@@ -886,7 +944,7 @@ class RuntimeParser {

if ((cc >= 97 && cc <= 122) || // a-z
(cc >= 65 && cc <= 90) || // A-Z
cc === 95 || cc === 47 || cc === 91) { // _/[
cc === 47 || cc === 91) { // /[
Copy link
Contributor Author

@stasm stasm Jan 22, 2018

Choose a reason for hiding this comment

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

I think this shouldn't check for / nor [ anymore? I'll fix it in a follow-up

const cc = this.currentPeek().charCodeAt(0);
const isDigit = cc >= 48 && cc <= 57; // 0-9
this.resetPeek();
return isDigit;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the value of this change?

Copy link
Contributor Author

@stasm stasm Jan 22, 2018

Choose a reason for hiding this comment

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

It makes isNumberStart consistent with isMessageIDStart and more importantly, it considers the char after the leading -. The previous version would return true upon seeing a dash right away and more checking was required in getLiteral.

if (allowPrivate && this.currentIs('-')) {
this.next();
return '-';
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should be able to return this.next(); here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to return current here but first, we advance the index.

@stasm stasm merged commit 4588bec into projectfluent:master Jan 23, 2018
@stasm stasm deleted the private-messages branch January 23, 2018 14:09
@zbraniecki zbraniecki mentioned this pull request Jan 26, 2018
4 tasks
@stasm stasm added this to fluent-syntax 0.6.0 in fluent-syntax May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
fluent-syntax
fluent-syntax 0.6.0
Development

Successfully merging this pull request may close these issues.

None yet

2 participants