rouge icon indicating copy to clipboard operation
rouge copied to clipboard

OCaml: lexing of double quotes as character (between single quotes)

Open maroneze opened this issue 4 years ago • 1 comments

Name of the lexer ocaml

Code sample

let isquote c = match c with '"' | '\'' -> true | _ -> false

Link to sample on rouge.jneen.net : http://rouge.jneen.net/v3.26.0/ocaml/bGV0IGlzcXVvdGUgYyA9IG1hdGNoIGMgd2l0aCAnIicgfCAnXCcnIC0-IHRydWUgfCBfIC0-IGZhbHNl

Additional context

After the " inside the simple quotes, the rest of the code is colored as if inside a string.

I tried modifying lib/rouge/lexers/ocaml.rb but didn't succeed. There is a rule rule %r/'[.]'/, Str::Char that should match, but unless I completely remove the rule rule %r/"/, Str::Double, :string, it seems to take priority over the previous one, and lexing fails.

FWIW, I just noticed that '\"' is equivalent to '"' in OCaml, and the former is correctly lexed, so there's always a way to change the source code to avoid the issue.

maroneze avatar Jul 20 '21 08:07 maroneze

This issue has been automatically marked as stale because it has not had any activity for more than a year. It will be closed if no additional activity occurs within the next 14 days. If you would like this issue to remain open, please reply and let us know if the issue is still reproducible.

stale[bot] avatar Aug 13 '22 08:08 stale[bot]