Skip to content

Inline Patterns may start with any character. #150

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 2 commits into from
Feb 8, 2018
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
14 changes: 6 additions & 8 deletions fluent-syntax/src/ftlstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,20 @@ export class FTLParserStream extends ParserStream {
return isDigit;
}

isCharPatternStart(ch) {
isCharPatternContinuation(ch) {
return !includes(SPECIAL_LINE_START_CHARS, ch);
}

isPeekPatternStart() {
this.peekInlineWS();

const ch = this.currentPeek();

if (ch === '\n') {
return this.isPeekNextLinePatternStart();
// Inline Patterns may start with any char.
if (ch !== undefined && ch !== '\n') {
return true;
}

const isPattern = this.isCharPatternStart(this.currentPeek());
this.resetPeek();
return isPattern;
return this.isPeekNextLinePatternStart();
}

isPeekNextLineZeroFourStyleComment() {
Expand Down Expand Up @@ -276,7 +274,7 @@ export class FTLParserStream extends ParserStream {
return false;
}

if (!this.isCharPatternStart(this.currentPeek())) {
if (!this.isCharPatternContinuation(this.currentPeek())) {
this.resetPeek();
return false;
}
Expand Down
64 changes: 64 additions & 0 deletions fluent-syntax/test/fixtures_structure/leading_dots.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
key01 = .Value
key02 = …Value
key03 = {"."}Value
key04 =
{"."}Value

key05 = Value
{"."}Continued

key06 = .Value
{"."}Continued

# ERROR (attr .Continued must have a value)
key07 = Value
.Continued

# ERROR (attr .Value must have a value)
key08 =
.Value

# ERROR (attr .Value must have a value)
key09 =
.Value
Continued

key10 =
.Value = which looks like an attribute
Continued

key11 =
{"."}Value = which looks like an attribute
Continued

key12 =
.accesskey =
A

key13 =
.attribute = .Value

key14 =
.attribute =
{"."}Value

key15 =
{ 1 ->
[one] .Value
*[other]
{"."}Value
}

# ERROR (variant must have a value)
key16 =
{ 1 ->
*[one]
.Value
}

# ERROR (unclosed placeable)
key17 =
{ 1 ->
*[one] Value
.Continued
}
Loading