Skip to content

Commit e9a7b56

Browse files
authored
Merge pull request #156 from aspeddro/relax-async-await-rule
fix: allow `async` as valid identifier
2 parents 2b7dcd1 + bb28c78 commit e9a7b56

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

grammar.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module.exports = grammar({
107107
[$.variant_declaration],
108108
[$.unit, $._function_type_parameter_list],
109109
[$.functor_parameter, $.module_primary_expression, $.module_identifier_path],
110+
[$._reserved_identifier, $.function]
110111
],
111112

112113
rules: {
@@ -1358,6 +1359,7 @@ module.exports = grammar({
13581359

13591360
value_identifier: $ => choice(
13601361
/[a-z_][a-zA-Z0-9_']*/,
1362+
$._reserved_identifier,
13611363
$._escape_identifier,
13621364
),
13631365

@@ -1488,6 +1490,10 @@ module.exports = grammar({
14881490
lparen: $ => alias($._lparen, '('),
14891491
rparen: $ => alias($._rparen, ')'),
14901492
uncurry: $ => '.',
1493+
1494+
_reserved_identifier: $ => choice(
1495+
'async'
1496+
)
14911497
},
14921498
});
14931499

queries/highlights.scm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@
112112
"type"
113113
"and"
114114
"assert"
115-
"async"
116115
"await"
117116
"with"
118117
"unpack"
119118
"lazy"
120119
] @keyword
121120

121+
((function "async" @keyword))
122+
122123
[
123124
"if"
124125
"else"

test/corpus/functions.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ a => 1
1212
(h, trailing,) => 5
1313
(set, kv) => 2
1414
(a, .b, c, .d) => 7
15+
(async) => 1
1516

1617
---
1718

@@ -53,7 +54,12 @@ a => 1
5354
(parameter
5455
(uncurry)
5556
(value_identifier)))
56-
(number))))
57+
(number)))
58+
(expression_statement
59+
(function
60+
(formal_parameters
61+
(parameter (value_identifier)))
62+
(number))))
5763

5864
===================================================
5965
Type annotations

test/corpus/let_bindings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ let b = a
77
let c = #foo
88
let list = 1
99
let a = list
10+
let async = 1
1011
export d = 5
1112

1213
---
@@ -17,6 +18,7 @@ export d = 5
1718
(let_binding (value_identifier) (polyvar (polyvar_identifier)))
1819
(let_binding (value_identifier) (number))
1920
(let_binding (value_identifier) (value_identifier))
21+
(let_binding (value_identifier) (number))
2022
(let_binding (value_identifier) (number)))
2123

2224
============================================

test/highlight/functions.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ let inc = n => n + 1
55
let uncurry = (. u, .x) => (u, x)
66
// ^ operator
77
// ^ operator
8+
9+
let get = async (id) => id
10+
// ^ keyword

0 commit comments

Comments
 (0)