From 1100478553de97378f64ff034098fb3a1cef61a3 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 | 11 +- common/test/corpus/expressions.txt | 17 + php/src/grammar.json | 48 + php/src/parser.c | 135681 +++++++++++++------------- php_only/src/grammar.json | 48 + php_only/src/parser.c | 125167 ++++++++++++------------ 6 files changed, 131977 insertions(+), 128995 deletions(-) diff --git a/common/define-grammar.js b/common/define-grammar.js index 5c6b30bb..baf59fea 100644 --- a/common/define-grammar.js +++ b/common/define-grammar.js @@ -939,11 +939,20 @@ module.exports = function defineGrammar(dialect) { parenthesized_expression: $ => seq('(', $._expression, ')'), - class_constant_access_expression: $ => seq( + class_constant_access_expression: $ => choice( + $._class_constant_access_expression, + $._dynamic_class_constant_access_expression, + ), + _class_constant_access_expression: $ => seq( $._scope_resolution_qualifier, '::', choice($.name, alias($._reserved_identifier, $.name)), ), + _dynamic_class_constant_access_expression: $ => seq( + $._scope_resolution_qualifier, + '::', + alias(seq('{', $._expression, '}'), $.name), + ), print_intrinsic: $ => seq( keyword('print'), $._expression, diff --git a/common/test/corpus/expressions.txt b/common/test/corpus/expressions.txt index 274ad1d1..03836228 100644 --- a/common/test/corpus/expressions.txt +++ b/common/test/corpus/expressions.txt @@ -1543,3 +1543,20 @@ $statement = match ($a) { ) ) +=============================================== +Dynamic class constant access +=============================================== + +