Skip to content

Commit

Permalink
Fix lexing of quoted strings in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Apr 25, 2024
1 parent 1c96f66 commit f07d346
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 57 deletions.
4 changes: 1 addition & 3 deletions src/ocaml/preprocess/lexer_raw.mll
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,8 @@ and comment state = parse
state.buffer <- buffer;
Buffer.add_char state.buffer '\"';
comment state lexbuf }
| "{" ('%' '%'? extattrident blank*)? lowercase* "|"
| "{" ('%' '%'? extattrident blank*)? (lowercase* as delim) "|"
{
let delim = Lexing.lexeme lexbuf in
let delim = String.sub delim ~pos:1 ~len:(String.length delim - 2) in
state.string_start_loc <- Location.curr lexbuf;
Buffer.add_string state.buffer (Lexing.lexeme lexbuf);
(catch (quoted_string delim state lexbuf) (fun e l -> match e with
Expand Down
58 changes: 4 additions & 54 deletions tests/test-dirs/errors/issue1753.t
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
FIXME: should be accepted
should be accepted
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {%ext|babar|} *)
> EOF
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"type": "typer",
"sub": [
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"message": "String literal begins here"
}
],
"valid": true,
"message": "This comment contains an unterminated string literal"
}
null

should fail
$ $MERLIN single errors -filename main.ml <<'EOF' | \
Expand Down Expand Up @@ -62,37 +37,12 @@ should fail
"message": "This comment contains an unterminated string literal"
}

FIXME: should accept
should accept
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {%ext id|babar|id} *)
> EOF
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"type": "typer",
"sub": [
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"message": "String literal begins here"
}
],
"valid": true,
"message": "This comment contains an unterminated string literal"
}
null

should accept
$ $MERLIN single errors -filename main.ml <<'EOF' | \
Expand Down

0 comments on commit f07d346

Please sign in to comment.