Skip to content

feat: raw identifier syntax#28

Closed
davesnx wants to merge 2 commits intomainfrom
support-raw-identifier-syntax
Closed

feat: raw identifier syntax#28
davesnx wants to merge 2 commits intomainfrom
support-raw-identifier-syntax

Conversation

@davesnx
Copy link
Copy Markdown
Member

@davesnx davesnx commented Feb 23, 2026

Add support for raw identifiers (OCaml 5.2 / RFC 27) to the MLX lexer, allowing keywords to be used as identifiers via the # prefix.

This unblocks polyvariant tags that collide with OCaml keywords, which is common for HTML attribute values:

`\#lazy    (* loading="lazy" *)
`\#true    (* aria-pressed="true" *)
`\#false   (* aria-pressed="false" *)
`\#lazy    (* loading="lazy" *)`\#true    (* aria-pressed="true" *)`\#false   (* aria-pressed="false" *)

The implementation mirrors the OCaml compiler's lexer: a raw_ident_escape is matched before the regular identifier rules, emitting LIDENT directly without keyword-table lookup. Applied to LABEL, OPTLABEL, LIDENT, and JSX_LIDENT rules across mlx/lexer.mll and ocamlmerlin_mlx/ocaml/preprocess/lexer_raw.mll.

It also allows <#lazy> as a component name

@andreypopp
Copy link
Copy Markdown
Member

I wonder if we should exercise updating to 5.4 AST instead? This will get us this and other features like named tuples for free.

@davesnx
Copy link
Copy Markdown
Member Author

davesnx commented Feb 24, 2026

Totally made the update here #29

@davesnx davesnx closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants