Skip to content

Commit

Permalink
fix: final modifier with constant visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Jan 6, 2024
1 parent 2f791d9 commit ed03d32
Show file tree
Hide file tree
Showing 6 changed files with 5,861 additions and 5,840 deletions.
4 changes: 2 additions & 2 deletions common/define-grammar.js
Expand Up @@ -354,11 +354,11 @@ module.exports = function defineGrammar(dialect) {

const_declaration: $ => $._const_declaration,

_class_const_declaration: $ => seq(
_class_const_declaration: $ => prec(1, seq(
optional(field('attributes', $.attribute_list)),
optional(field('modifier', $.final_modifier)),
$._const_declaration,
),
)),

_const_declaration: $ => seq(
optional($.visibility_modifier),
Expand Down
6 changes: 6 additions & 0 deletions common/test/corpus/class.txt
Expand Up @@ -182,6 +182,7 @@ class Foo {
protected const C = 3;
private const D = 4;
final const E = 5;
final public const F = 6;
}

---
Expand Down Expand Up @@ -210,6 +211,11 @@ class Foo {
(final_modifier)
(const_element (name) (integer))
)
(const_declaration
(final_modifier)
(visibility_modifier)
(const_element (name) (integer))
)
)
)
)
Expand Down
81 changes: 44 additions & 37 deletions php/src/grammar.json
Expand Up @@ -1464,45 +1464,49 @@
"name": "_const_declaration"
},
"_class_const_declaration": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "attributes",
"content": {
"type": "SYMBOL",
"name": "attribute_list"
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "attributes",
"content": {
"type": "SYMBOL",
"name": "attribute_list"
}
},
{
"type": "BLANK"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "modifier",
"content": {
"type": "SYMBOL",
"name": "final_modifier"
]
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "modifier",
"content": {
"type": "SYMBOL",
"name": "final_modifier"
}
},
{
"type": "BLANK"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_const_declaration"
}
]
]
},
{
"type": "SYMBOL",
"name": "_const_declaration"
}
]
}
},
"_const_declaration": {
"type": "SEQ",
Expand Down Expand Up @@ -8953,6 +8957,9 @@
[
"if_statement"
],
[
"_class_const_declaration"
],
[
"namespace_name"
],
Expand Down

0 comments on commit ed03d32

Please sign in to comment.