Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 7097f33

Browse files
author
Iwan
committed
Rename Character token to Codepoint token.
Codepoint makes more sense with unicode
1 parent de843ea commit 7097f33

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/res_core.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ let parseConstant p =
917917
s
918918
in
919919
Pconst_string(txt, None)
920-
| Character {c; original} ->
920+
| Codepoint {c; original} ->
921921
if p.mode = ParseForTypeChecker then
922922
Pconst_char c
923923
else
@@ -1113,7 +1113,7 @@ let rec parsePattern ?(alias=true) ?(or_=true) p =
11131113
let loc = mkLoc startPos endPos in
11141114
Ast_helper.Pat.construct ~loc
11151115
(Location.mkloc (Longident.Lident (Token.toString token)) loc) None
1116-
| Int _ | String _ | Float _ | Character _ | Minus | Plus ->
1116+
| Int _ | String _ | Float _ | Codepoint _ | Minus | Plus ->
11171117
let c = parseConstant p in
11181118
begin match p.token with
11191119
| DotDot ->
@@ -1858,7 +1858,7 @@ and parseAtomicExpr p =
18581858
let loc = mkLoc startPos p.prevEndPos in
18591859
Ast_helper.Exp.construct ~loc
18601860
(Location.mkloc (Longident.Lident (Token.toString token)) loc) None
1861-
| Int _ | String _ | Float _ | Character _ ->
1861+
| Int _ | String _ | Float _ | Codepoint _ ->
18621862
let c = parseConstant p in
18631863
let loc = mkLoc startPos p.prevEndPos in
18641864
Ast_helper.Exp.constant ~loc c

src/res_grammar.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ let isSignatureItemStart = function
134134
| _ -> false
135135

136136
let isAtomicPatternStart = function
137-
| Token.Int _ | String _ | Character _ | Backtick
137+
| Token.Int _ | String _ | Codepoint _ | Backtick
138138
| Lparen | Lbracket | Lbrace
139139
| Underscore
140140
| Lident _ | Uident _ | List
@@ -144,7 +144,7 @@ let isAtomicPatternStart = function
144144

145145
let isAtomicExprStart = function
146146
| Token.True | False
147-
| Int _ | String _ | Float _ | Character _
147+
| Int _ | String _ | Float _ | Codepoint _
148148
| Backtick
149149
| Uident _ | Lident _ | Hash
150150
| Lparen
@@ -165,7 +165,7 @@ let isAtomicTypExprStart = function
165165

166166
let isExprStart = function
167167
| Token.True | False
168-
| Int _ | String _ | Float _ | Character _ | Backtick
168+
| Int _ | String _ | Float _ | Codepoint _ | Backtick
169169
| Underscore (* _ => doThings() *)
170170
| Uident _ | Lident _ | Hash
171171
| Lparen | List | Module | Lbracket | Lbrace
@@ -194,7 +194,7 @@ let isStructureItemStart = function
194194
| _ -> false
195195

196196
let isPatternStart = function
197-
| Token.Int _ | Float _ | String _ | Character _ | Backtick | True | False | Minus | Plus
197+
| Token.Int _ | Float _ | String _ | Codepoint _ | Backtick | True | False | Minus | Plus
198198
| Lparen | Lbracket | Lbrace | List
199199
| Underscore
200200
| Lident _ | Uident _ | Hash
@@ -301,7 +301,7 @@ let isJsxChildStart = isAtomicExprStart
301301

302302
let isBlockExprStart = function
303303
| Token.At | Hash | Percent | Minus | MinusDot | Plus | PlusDot | Bang
304-
| True | False | Float _ | Int _ | String _ | Character _ | Lident _ | Uident _
304+
| True | False | Float _ | Int _ | String _ | Codepoint _ | Lident _ | Uident _
305305
| Lparen | List | Lbracket | Lbrace | Forwardslash | Assert
306306
| Lazy | If | For | While | Switch | Open | Module | Exception | Let
307307
| LessThan | Backtick | Try | Underscore -> true

src/res_scanner.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ let scanEscape scanner =
451451
let contents = (String.sub [@doesNotRaise]) scanner.src offset (scanner.offset - offset) in
452452
next scanner; (* Consume \' *)
453453
(* TODO: do we know it's \' ? *)
454-
Token.Character {c = codepoint; original = contents}
454+
Token.Codepoint {c = codepoint; original = contents}
455455

456456
let scanSingleLineComment scanner =
457457
let startOff = scanner.offset in
@@ -664,7 +664,7 @@ let rec scan scanner =
664664
| ch, '\'' ->
665665
let offset = scanner.offset + 1 in
666666
next3 scanner;
667-
Token.Character {c = ch; original = (String.sub [@doesNotRaise]) scanner.src offset 1}
667+
Token.Codepoint {c = ch; original = (String.sub [@doesNotRaise]) scanner.src offset 1}
668668
| ch, _ ->
669669
next scanner;
670670
let offset = scanner.offset in
@@ -675,7 +675,7 @@ let rec scan scanner =
675675
if scanner.ch = '\'' then (
676676
let contents = (String.sub [@doesNotRaise]) scanner.src offset length in
677677
next scanner;
678-
Token.Character {c = Obj.magic codepoint; original = contents}
678+
Token.Codepoint {c = Obj.magic codepoint; original = contents}
679679
) else (
680680
scanner.ch <- ch;
681681
scanner.offset <- offset;

src/res_token.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Comment = Res_comment
33
type t =
44
| Open
55
| True | False
6-
| Character of {c: char; original: string}
6+
| Codepoint of {c: char; original: string}
77
| Int of {i: string; suffix: char option}
88
| Float of {f: string; suffix: char option}
99
| String of string
@@ -88,7 +88,7 @@ let precedence = function
8888
let toString = function
8989
| Open -> "open"
9090
| True -> "true" | False -> "false"
91-
| Character {original} -> "character '" ^ original ^ "'"
91+
| Codepoint {original} -> "codepoint '" ^ original ^ "'"
9292
| String s -> "string \"" ^ s ^ "\""
9393
| Lident str -> str
9494
| Uident str -> str

0 commit comments

Comments
 (0)