Skip to content

Commit 1f5989b

Browse files
committed
Add internal soft keyword as simple identifier
1 parent a988e0a commit 1f5989b

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

grammar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ module.exports = grammar({
7272
[$.platform_modifier, $.simple_identifier],
7373
// "data", "inner" as class modifier or id
7474
[$.class_modifier, $.simple_identifier],
75+
// "internal" as visibility modifier conflicts with internal as an identifier
76+
[$.visibility_modifier, $.simple_identifier],
7577

7678
// "<x>.<y> = z assignment conflicts with <x>.<y>() function call"
7779
[$._postfix_unary_expression, $._expression],
@@ -1110,6 +1112,7 @@ module.exports = grammar({
11101112
"get",
11111113
"enum",
11121114
"annotation",
1115+
"internal",
11131116
// TODO: More soft keywords
11141117
),
11151118

test/corpus/classes.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Classes
44

55
class Empty
66
class Empty2 {}
7+
internal class Empty3 {}
78

89
--------------------------------------------------------------------------------
910

@@ -12,6 +13,11 @@ class Empty2 {}
1213
(type_identifier))
1314
(class_declaration
1415
(type_identifier)
16+
(class_body))
17+
(class_declaration
18+
(modifiers
19+
(visibility_modifier))
20+
(type_identifier)
1521
(class_body)))
1622

1723
================================================================================
@@ -401,11 +407,23 @@ interface Foo {
401407
fun bar()
402408
}
403409

410+
internal interface Bar {
411+
fun foo()
412+
}
413+
404414
--------------------------------------------------------------------------------
405415

406416
(source_file
407417
(class_declaration
408418
(type_identifier)
419+
(class_body
420+
(function_declaration
421+
(simple_identifier)
422+
(function_value_parameters))))
423+
(class_declaration
424+
(modifiers
425+
(visibility_modifier))
426+
(type_identifier)
409427
(class_body
410428
(function_declaration
411429
(simple_identifier)

test/corpus/expressions.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ foo.forEach { (index, value) -> 2 }
328328

329329
annotations.filter { annotation -> true }
330330

331+
availability.associate { internal -> false }.toMap()
332+
331333
--------------------------------------------------------------------------------
332334

333335
(source_file
@@ -359,7 +361,26 @@ annotations.filter { annotation -> true }
359361
(variable_declaration
360362
(simple_identifier)))
361363
(statements
362-
(boolean_literal)))))))
364+
(boolean_literal))))))
365+
(call_expression
366+
(navigation_expression
367+
(call_expression
368+
(navigation_expression
369+
(simple_identifier)
370+
(navigation_suffix
371+
(simple_identifier)))
372+
(call_suffix
373+
(annotated_lambda
374+
(lambda_literal
375+
(lambda_parameters
376+
(variable_declaration
377+
(simple_identifier)))
378+
(statements
379+
(boolean_literal))))))
380+
(navigation_suffix
381+
(simple_identifier)))
382+
(call_suffix
383+
(value_arguments))))
363384

364385
================================================================================
365386
Function call with trailing lambda

0 commit comments

Comments
 (0)