Skip to content

Commit 8f5c6de

Browse files
authored
Merge pull request rescript-lang#185 from nkrkv/fix-tick-in-modules
Allow ticks in more identifiers
2 parents 0e76ceb + 1e83ffc commit 8f5c6de

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

grammar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,12 +1320,12 @@ module.exports = grammar({
13201320
$.block,
13211321
),
13221322

1323-
variant_identifier: $ => /[A-Z][a-zA-Z0-9_]*/,
1323+
variant_identifier: $ => /[A-Z][a-zA-Z0-9_']*/,
13241324

13251325
polyvar_identifier: $ => seq(
13261326
'#',
13271327
choice(
1328-
/[a-zA-Z0-9_]+/,
1328+
/[a-zA-Z0-9_']+/,
13291329
seq(
13301330
optional('\\'),
13311331
alias($.string, $.polyvar_string),
@@ -1334,7 +1334,7 @@ module.exports = grammar({
13341334
),
13351335

13361336
type_identifier: $ => choice(
1337-
/[a-z_'][a-zA-Z0-9_]*/,
1337+
/[a-z_'][a-zA-Z0-9_']*/,
13381338
$._escape_identifier,
13391339
),
13401340

@@ -1346,7 +1346,7 @@ module.exports = grammar({
13461346

13471347
_escape_identifier: $ => token(seq('\\"', /[^"]+/ , '"')),
13481348

1349-
module_identifier: $ => /[A-Z][a-zA-Z0-9_]*/,
1349+
module_identifier: $ => /[A-Z][a-zA-Z0-9_']*/,
13501350

13511351
decorator_identifier: $ => /[a-zA-Z0-9_\.]+/,
13521352

test/corpus/modules.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ Alias
268268
===========================================
269269

270270
module Q = Foo.Bar.Qux
271+
module Foo' = Foo
271272

272273
---
273274

@@ -278,7 +279,10 @@ module Q = Foo.Bar.Qux
278279
(module_identifier_path
279280
(module_identifier)
280281
(module_identifier))
281-
(module_identifier))))
282+
(module_identifier)))
283+
(module_declaration
284+
(module_identifier)
285+
(module_identifier)))
282286

283287
===========================================
284288
Recursive

test/corpus/type_declarations.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ Opaque
33
===========================================
44

55
type t
6+
type t'
67
type \"type"
78

89
---
910

1011
(source_file
12+
(type_declaration (type_identifier))
1113
(type_declaration (type_identifier))
1214
(type_declaration (type_identifier)))
1315

@@ -151,6 +153,7 @@ Variant
151153

152154
type t =
153155
| A
156+
| A'
154157
| @live("t.D") D
155158
| B(anotherType)
156159
| C({foo: int, bar: string})
@@ -163,6 +166,7 @@ type t =
163166
(type_declaration
164167
(type_identifier)
165168
(variant_type
169+
(variant_declaration (variant_identifier))
166170
(variant_declaration (variant_identifier))
167171
(variant_declaration
168172
(decorator (decorator_identifier) (decorator_arguments (string (string_fragment))))
@@ -210,6 +214,7 @@ Polyvar
210214

211215
type t = [>
212216
| #AAA
217+
| #AAA'
213218
| #bbb(anotherType)
214219
| #"cc-cc"
215220
| #\"cc-cc"
@@ -228,6 +233,7 @@ type t<'w> = [M.t<'w>]
228233
(type_declaration
229234
(type_identifier)
230235
(polyvar_type
236+
(polyvar_declaration (polyvar_identifier))
231237
(polyvar_declaration (polyvar_identifier))
232238
(polyvar_declaration
233239
(polyvar_identifier) (polyvar_parameters (type_identifier)))

0 commit comments

Comments
 (0)