Skip to content

Commit

Permalink
feat: support quoted extensions in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Aug 21, 2024
1 parent 4f42b01 commit a8ab961
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/reason-parser/reason_declarative_lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ and comment buffer firstloc nestedloc = parse
false
)
}
| "{" (lowercase* as delim) "|"
| "{" ('%' '%'? extattrident blank*)? (lowercase* as delim) "|"
{ store_lexeme buffer lexbuf;
let stringloc = Location.curr lexbuf in
let terminated_string = quoted_string buffer delim lexbuf in
Expand Down
12 changes: 12 additions & 0 deletions test/extensions.t/input.re
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,15 @@ external%foo x: int => int = "caml_prim";

{%%M.foo| <hello>{x} |};
let x = {%M.foo bar| <hello>{|x|} |bar};

/* Double quotes inside quoted strings inside comments */
/* {|"|}, and */
/* [%foo {|"|}], and */
/* {%foo|"|} should be valid inside comments */

/* Comment delimiters inside quoted strings inside comments: */
/* {|*)|}, and */
/* [%foo {bar|*)|bar}], and */
/* {%foo bar|*)|bar} should be valid inside comments */


10 changes: 10 additions & 0 deletions test/extensions.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,13 @@ Format extensions

{%%M.foo | <hello>{x} |};
let x = {%M.foo bar| <hello>{|x|} |bar};

/* Double quotes inside quoted strings inside comments */
/* {|"|}, and */
/* [%foo {|"|}], and */
/* {%foo|"|} should be valid inside comments */

/* Comment delimiters inside quoted strings inside comments: */
/* {|*)|}, and */
/* [%foo {bar|*)|bar}], and */
/* {%foo bar|*)|bar} should be valid inside comments */

0 comments on commit a8ab961

Please sign in to comment.