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

WIP Broken Attributes should not break the whole Entry #249

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions fluent-syntax/src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,16 @@ export default class FluentParser {
const attrs = [];

while (true) {
const lineStart = ps.getIndex() + 1;
ps.expectIndent();
const attr = this.getAttribute(ps);
attrs.push(attr);

try {
const attr = this.getAttribute(ps);
attrs.push(attr);
} catch (err) {
ps.setIndex(lineStart);
return attrs;
}

if (!ps.isPeekNextLineAttributeStart()) {
break;
Expand Down
4 changes: 4 additions & 0 deletions fluent-syntax/src/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export class ParserStream {
return this.index;
}

setIndex(idx) {
return this.index = idx;
}

getPeekIndex() {
return this.peekIndex;
}
Expand Down
5 changes: 0 additions & 5 deletions fluent-syntax/test/reference_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ readdir(fixtures, function(err, filenames) {
// There's even a behavior fixture for this; it must have been a
// deliberate decision.
"select_expressions.ftl",

// Broken Attributes break the entire Entry right now.
// https://github.com/projectfluent/fluent.js/issues/237
"leading_dots.ftl",
"variant_lists.ftl"
];

for (const filename of ftlnames) {
Expand Down