Skip to content

Commit

Permalink
feat: add raw identifier syntax (#2796)
Browse files Browse the repository at this point in the history
* feat: add raw identifier syntax

* fix: record labels

* true / false

* more testing

* add changelog entry
  • Loading branch information
anmonteiro authored Dec 2, 2024
1 parent e49db1c commit b078858
Show file tree
Hide file tree
Showing 5 changed files with 653 additions and 804 deletions.
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

0 comments on commit b078858

Please sign in to comment.