Skip to content

Commit cdb1215

Browse files
committed
Add operator soft keyword as simple identifier
1 parent 1f1191e commit cdb1215

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

grammar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ module.exports = grammar({
7474
[$.class_modifier, $.simple_identifier],
7575
// "internal" as visibility modifier conflicts with internal as an identifier
7676
[$.visibility_modifier, $.simple_identifier],
77+
// "operator" as visibility modifier conflicts with operator as an identifier
78+
[$.function_modifier, $.simple_identifier],
7779

7880
// "<x>.<y> = z assignment conflicts with <x>.<y>() function call"
7981
[$._postfix_unary_expression, $._expression],
@@ -1113,6 +1115,7 @@ module.exports = grammar({
11131115
"enum",
11141116
"annotation",
11151117
"internal",
1118+
"operator",
11161119
// TODO: More soft keywords
11171120
),
11181121

test/corpus/expressions.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ annotations.filter { annotation -> true }
160160

161161
availability.associate { internal -> false }.toMap()
162162

163+
operators.filter { operator -> true }
164+
163165
--------------------------------------------------------------------------------
164166

165167
(source_file
@@ -209,7 +211,20 @@ availability.associate { internal -> false }.toMap()
209211
(navigation_suffix
210212
(simple_identifier)))
211213
(call_suffix
212-
(value_arguments))))
214+
(value_arguments)))
215+
(call_expression
216+
(navigation_expression
217+
(simple_identifier)
218+
(navigation_suffix
219+
(simple_identifier)))
220+
(call_suffix
221+
(annotated_lambda
222+
(lambda_literal
223+
(lambda_parameters
224+
(variable_declaration
225+
(simple_identifier)))
226+
(statements
227+
(boolean_literal)))))))
213228

214229
================================================================================
215230
Value declaration with receiver type

test/corpus/functions.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ Top-level functions
33
==================
44

55
fun main() {}
6+
operator fun main() {}
67

78
---
89

910
(source_file
1011
(function_declaration
11-
(simple_identifier) (function_value_parameters)
12+
(simple_identifier)
13+
(function_value_parameters)
14+
(function_body))
15+
(function_declaration
16+
(modifiers
17+
(function_modifier))
18+
(simple_identifier)
19+
(function_value_parameters)
1220
(function_body)))
1321

1422
==================

0 commit comments

Comments
 (0)