Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add raw identifier syntax #2796

Merged
merged 5 commits into from
Dec 2, 2024
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- rtop: read `~/.config/rtop/init.re` configuration file (@anmonteiro, [#2813])
- the `-init FILE` flag works as before
- rtop: ignore `~/.ocamlinit.ml` or `~/.config/utop/init.ml` config files (@anmonteiro, [#2813])
- Add support for raw identifier syntax (@anmonteiro,
[#2796](https://github.com/reasonml/reason/pull/2796))

## 3.14.0

Expand Down
5 changes: 4 additions & 1 deletion src/reason-parser/reason_declarative_lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ let hex_float_literal =
(['p' 'P'] ['+' '-']? ['0'-'9'] ['0'-'9' '_']* )?

let literal_modifier = ['G'-'Z' 'g'-'z']
let raw_ident_escape = "\\#"

rule token state = parse
| "\\" newline {
Expand All @@ -408,6 +409,8 @@ rule token state = parse
{ QUESTION }
| "=?"
{ set_lexeme_length lexbuf 1; EQUAL }
| raw_ident_escape (lowercase identchar * as name)
{ LIDENT name }
| lowercase identchar *
{ let s = Lexing.lexeme lexbuf in
try Hashtbl.find keyword_table s
Expand Down Expand Up @@ -521,7 +524,7 @@ rule token state = parse
{ CHAR (char_for_decimal_code lexbuf 2) }
| "'\\" 'x' ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] "'"
{ CHAR (char_for_hexadecimal_code lexbuf 3) }
| "'" (("\\" _) as esc)
| "'" (("\\" [^ '#']) as esc)
{ raise_error (Location.curr lexbuf) (Illegal_escape esc);
token state lexbuf
}
Expand Down
Loading
Loading