Skip to content

Commit 0b6fdd4

Browse files
committed
Add operator soft keyword as simple identifier
1 parent 1f5989b commit 0b6fdd4

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
@@ -330,6 +330,8 @@ annotations.filter { annotation -> true }
330330

331331
availability.associate { internal -> false }.toMap()
332332

333+
operators.filter { operator -> true }
334+
333335
--------------------------------------------------------------------------------
334336

335337
(source_file
@@ -380,7 +382,20 @@ availability.associate { internal -> false }.toMap()
380382
(navigation_suffix
381383
(simple_identifier)))
382384
(call_suffix
383-
(value_arguments))))
385+
(value_arguments)))
386+
(call_expression
387+
(navigation_expression
388+
(simple_identifier)
389+
(navigation_suffix
390+
(simple_identifier)))
391+
(call_suffix
392+
(annotated_lambda
393+
(lambda_literal
394+
(lambda_parameters
395+
(variable_declaration
396+
(simple_identifier)))
397+
(statements
398+
(boolean_literal)))))))
384399

385400
================================================================================
386401
Function call with trailing lambda

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)