From a041c48af00b0b820517b904fc17c899e30ad896 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Tue, 1 Oct 2024 08:16:34 -0500 Subject: [PATCH] feat: add asymmetric property visibility --- common/define-grammar.js | 15 ++++++-- test/corpus/class.txt | 79 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/common/define-grammar.js b/common/define-grammar.js index 48697339..7a0e6827 100644 --- a/common/define-grammar.js +++ b/common/define-grammar.js @@ -423,10 +423,17 @@ module.exports = function defineGrammar(dialect) { ), ), - visibility_modifier: _ => choice( - keyword('public'), - keyword('protected'), - keyword('private'), + visibility_modifier: $ => seq( + choice( + keyword('public'), + keyword('protected'), + keyword('private'), + ), + optional(seq( + token.immediate('('), + alias($.name, $.operation), + token.immediate(')'), + )), ), function_definition: $ => seq( diff --git a/test/corpus/class.txt b/test/corpus/class.txt index 38f2fbe8..f00f886c 100644 --- a/test/corpus/class.txt +++ b/test/corpus/class.txt @@ -1010,3 +1010,82 @@ class User implements Named { (name)))) (name) (compound_statement))))))) + +========================================= +Asymmetric Property Visibility +========================================= + +