From fab0c757f208eb663fcf40ddb09d8f8ede8b59c9 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Fri, 5 Jan 2024 12:55:42 -0600 Subject: [PATCH] feat: add support for dynamic class constant fetch --- common/define-grammar.js | 6 +- common/test/corpus/expressions.txt | 15 + php/src/grammar.json | 22 + php/src/parser.c | 129519 +++++++++++++------------- php_only/src/grammar.json | 22 + php_only/src/parser.c | 127799 ++++++++++++------------- 6 files changed, 129099 insertions(+), 128284 deletions(-) diff --git a/common/define-grammar.js b/common/define-grammar.js index 5c6b30bb..63ebda40 100644 --- a/common/define-grammar.js +++ b/common/define-grammar.js @@ -942,7 +942,11 @@ module.exports = function defineGrammar(dialect) { class_constant_access_expression: $ => seq( $._scope_resolution_qualifier, '::', - choice($.name, alias($._reserved_identifier, $.name)), + choice( + $.name, + alias($._reserved_identifier, $.name), + seq('{', alias($._expression, $.name), '}'), + ), ), print_intrinsic: $ => seq( diff --git a/common/test/corpus/expressions.txt b/common/test/corpus/expressions.txt index 274ad1d1..0edf53fc 100644 --- a/common/test/corpus/expressions.txt +++ b/common/test/corpus/expressions.txt @@ -1543,3 +1543,18 @@ $statement = match ($a) { ) ) +=============================================== +Dynamic class constant access +=============================================== + +