Skip to content

Commit

Permalink
Merge pull request #236 from calebdw/static_modifier
Browse files Browse the repository at this point in the history
fix: use $.static_modifier instead of raw string
  • Loading branch information
calebdw authored Mar 22, 2024
2 parents 8040208 + 8fc97bb commit 29838ad
Show file tree
Hide file tree
Showing 10 changed files with 152,901 additions and 152,872 deletions.
2 changes: 1 addition & 1 deletion common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ module.exports = function defineGrammar(dialect) {

anonymous_function_creation_expression: $ => seq(
optional(field('attributes', $.attribute_list)),
optional(keyword('static')),
optional(field('static_modifier', $.static_modifier)),
keyword('function'),
optional(field('reference_modifier', $.reference_modifier)),
field('parameters', $.formal_parameters),
Expand Down
16 changes: 15 additions & 1 deletion common/test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ header_register_callback(
ob_start(function($buffer) use (&$storage) { $storage .= $buffer; }, 20);
ob_start(function($buffer) use (&$storage,) { $storage .= $buffer; }, 20);

static function &($a) { return $a; };

---

(program
Expand Down Expand Up @@ -705,7 +707,19 @@ ob_start(function($buffer) use (&$storage,) { $storage .= $buffer; }, 20);
body: (compound_statement (expression_statement (augmented_assignment_expression
left: (variable_name (name))
right: (variable_name (name)))))))
(argument (integer))))))
(argument (integer)))))
(expression_statement
(anonymous_function_creation_expression
static_modifier: (static_modifier)
reference_modifier: (reference_modifier)
parameters: (formal_parameters
(simple_parameter
name: (variable_name
(name))))
body: (compound_statement
(return_statement
(variable_name
(name)))))))


================================
Expand Down
9 changes: 9 additions & 0 deletions common/test/highlight/keywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
function a() {}
// <- @keyword

static function a() {}
// <- @keyword

static function () {}
// <- @keyword

static fn () => 1;
// <- @keyword

abstract class A
// <- @keyword
// ^^^^^ @keyword
Expand Down
12 changes: 5 additions & 7 deletions php/src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4945,14 +4945,12 @@
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"type": "FIELD",
"name": "static_modifier",
"content": {
"type": "PATTERN",
"value": "static",
"flags": "i"
},
"named": false,
"value": "static"
"type": "SYMBOL",
"name": "static_modifier"
}
},
{
"type": "BLANK"
Expand Down
10 changes: 10 additions & 0 deletions php/src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,16 @@
"named": true
}
]
},
"static_modifier": {
"multiple": false,
"required": false,
"types": [
{
"type": "static_modifier",
"named": true
}
]
}
},
"children": {
Expand Down
Loading

0 comments on commit 29838ad

Please sign in to comment.