Skip to content
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
3 changes: 2 additions & 1 deletion spec/fluent.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Term ::= "-" Identifier blank_inline? "=" blank_inline? Value Att

/* Adjacent comment lines of the same comment type are joined together during
* the AST construction. */
CommentLine ::= ("###" | "##" | "#") ("\u0020" /.*/)? line_end
CommentLine ::= ("###" | "##" | "#") ("\u0020" comment_char*)? line_end
comment_char ::= any_char - line_end

/* Junk represents unparsed content.
*
Expand Down
8 changes: 7 additions & 1 deletion syntax/grammar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ let CommentLine = defer(() =>
maybe(
sequence(
string(" "),
regex(/.*/).abstract)),
repeat(comment_char)
.map(join).abstract)),
line_end)
.map(flatten(1))
.map(keep_abstract)
.chain(list_into(FTL.Comment)));

let comment_char = defer(() =>
and(
not(line_end),
any_char));

/* -------------------------------------------------------------------------- */
/* Junk represents unparsed content.
*
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/cr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"type": "Resource",
"body": [
{
"type": "Junk",
"annotations": [],
"content": "### This entire file uses CR as EOL.\r\rerr01 = Value 01\rerr02 = Value 02\r\rerr03 =\r\r Value 03\r Continued\r\r .title = Title\r\rerr04 = { \"str\r\rerr05 = { $sel -> }\r"
"type": "ResourceComment",
"content": "This entire file uses CR as EOL.\r\rerr01 = Value 01\rerr02 = Value 02\r\rerr03 =\r\r Value 03\r Continued\r\r .title = Title\r\rerr04 = { \"str\r\rerr05 = { $sel -> }\r"
}
]
}